{"record":{"id":"ff40bcbd34f99170","repo":"apache/beam","slug":"failed-to-discover-column-v","errorCode":null,"errorMessage":"failed to discover column: %v","messagePattern":"failed to discover column: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/databaseio/database.go","lineNumber":179,"sourceCode":"\t}\n\tdefer db.Close()\n\tprojection := \"*\"\n\tif len(f.Columns) > 0 {\n\t\tprojection = strings.Join(f.Columns, \",\")\n\t}\n\tdql := fmt.Sprintf(\"SELECT %v FROM  %v WHERE 1 = 0\", projection, f.Table)\n\tquery, err := db.Prepare(dql)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to prepare query: %v\", f.Table)\n\t}\n\tdefer query.Close()\n\trows, err := query.Query()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to query: %v\", f.Table)\n\t}\n\tcolumns, err := rows.Columns()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to discover column: %v\", f.Table)\n\t}\n\t//TODO move to Setup methods\n\tmapper, err := newWriterRowMapper(columns, f.Type.T)\n\tif err != nil {\n\t\treturn errors.WithContext(err, \"creating row mapper\")\n\t}\n\twriter, err := newWriter(f.Driver, f.BatchSize, f.Table, columns)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar val beam.X\n\tfor iter(&val) {\n\t\tvar row []any\n\t\tvar data map[string]any\n\t\tif writer, ok := val.(Writer); ok {\n\t\t\tif data, err = writer.SaveData(); err == nil {\n\t\t\t\trow = make([]any, len(columns))\n\t\t\t\tfor i, column := range columns {","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/databaseio/database.go#L161-L197","documentation":"Raised when rows.Columns() fails on the (empty) result set of the schema-probe query. The library reads the result-set column names to build a row mapper for inserts; this failure means the driver could not report the result-set metadata. It is rare compared to prepare/query failures and usually indicates a driver bug or a broken connection when fetching metadata.","triggerScenarios":"Connection lost between query execution and metadata retrieval; a database/sql driver whose Rows implementation returns an error from Columns(); fetching metadata on an already-closed or exhausted connection.","commonSituations":"Buggy or third-party drivers with incomplete database/sql implementations; network interruptions between executing the probe query and reading its metadata; extremely short connection lifetimes set via SetConnMaxLifetime.","solutions":["Check the wrapped driver error and verify the driver fully implements the database/sql Rows API.","Verify network stability between the worker and the database; retry the failing bundle.","Test rows.Columns() against the same driver in a small standalone program to isolate a driver bug.","Update the driver to a version with fixed metadata handling."],"exampleFix":"// before\nrows, _ := db.Query(\"SELECT * FROM users WHERE 1=0\")\n// metadata fetch may fail on broken conns\n// after\nif err := db.PingContext(ctx); err != nil { /* reconnect / fail fast */ }\nrows, err := db.Query(\"SELECT * FROM users WHERE 1=0\")","handlingStrategy":"try-catch","validationCode":"if err := db.PingContext(ctx); err != nil { return err }\nrows, err := db.Query(\"SELECT * FROM \" + table + \" WHERE 1 = 0\")\nif err != nil { return err }\nif _, err := rows.Columns(); err != nil { return fmt.Errorf(\"driver cannot report metadata: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err != nil {\n    return errors.Wrapf(err, \"could not read column metadata for table %q; suspect driver bug or dropped connection\", table)\n}","preventionTips":["Use a mature, well-maintained database/sql driver for your backend.","Smoke-test rows.Columns() against your driver in a small program before running the pipeline.","Keep connection lifetimes bounded so metadata calls don't hit dead connections.","Pin a known-good driver version; upgrade deliberately after testing."],"tags":["database","metadata","driver","beam-io"],"backgroundTag":"database-query-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}