{"record":{"id":"581a31a2f7e9d92d","repo":"apache/beam","slug":"bigqueryio-read-type-v-has-no-columns-to-select","errorCode":null,"errorMessage":"bigqueryio.Read: type %v has no columns to select","messagePattern":"bigqueryio\\.Read: type (.+?) has no columns to select","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/bigqueryio/bigquery.go","lineNumber":105,"sourceCode":"\n// Read reads all rows from the given table. The table must have a schema\n// compatible with the given type, t, and Read returns a PCollection<t>. If the\n// table has more rows than t, then Read is implicitly a projection.\nfunc Read(s beam.Scope, project, table string, t reflect.Type) beam.PCollection {\n\tmustParseTable(table)\n\n\ts = s.Scope(\"bigquery.Read\")\n\n\tstmt := constructSelectStatement(t, bigQueryTag, table)\n\n\treturn query(s, project, stmt, t)\n}\n\nfunc constructSelectStatement(t reflect.Type, tagKey string, table string) string {\n\tcolumns := structx.InferFieldNames(t, tagKey)\n\n\tif len(columns) == 0 {\n\t\tpanic(fmt.Sprintf(\"bigqueryio.Read: type %v has no columns to select\", t))\n\t}\n\n\tcolumnStr := strings.Join(columns, \", \")\n\n\treturn fmt.Sprintf(\"SELECT %v FROM [%v]\", columnStr, table)\n}\n\n// QueryOptions represents additional options for executing a query.\ntype QueryOptions struct {\n\t// UseStandardSQL enables BigQuery's Standard SQL dialect when executing a query.\n\tUseStandardSQL bool\n\t// Parameters are the query parameters for parameterized queries.\n\t// In the current implementation, user-defines types are not supported in Value field.\n\t// Use *bigquery.QueryParameterValue to build STRUCT/ARRAY parameters\n\t// or use go primitive types explicitly.\n\tparameters []bigquery.QueryParameter\n}\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/bigqueryio/bigquery.go#L87-L123","documentation":"bigqueryio.Read builds a SELECT statement from the struct's exported field names (via structx.InferFieldNames). If the type yields zero columns — e.g. an empty struct, an unexported-only struct, or a non-struct type — there is nothing to select, so the library panics.","triggerScenarios":"Calling bigqueryio.Read (or Query path) with a Go type t whose inferred column list is empty: struct with no exported fields, all fields ignored via the tag key, or a non-struct type.","commonSituations":"Defining a BigQuery row struct with only unexported fields, forgetting to export fields after a rename, or using a struct tag key that ignores all fields.","solutions":["Export the struct fields (capitalize) used as BigQuery columns.","Add or fix struct tags matching tagKey so fields are recognized as columns.","Use a non-empty struct type representing the table schema."],"exampleFix":"// before\ntype row struct { name string } // unexported: no columns\nbeam.ParDo0(s, ..., ) ; bigqueryio.Read(s, project, \"dataset\", \"table\", reflect.TypeOf(row{}))\n// after\ntype row struct { Name string `bigquery:\"name\"` }","handlingStrategy":"validation","validationCode":"t := reflect.TypeOf(row{})\nif t.Kind() != reflect.Struct || structx.InferFieldNames(t, \"bigquery\") == nil || len(structx.InferFieldNames(t, \"bigquery\")) == 0 {\n    return errors.New(\"row type must have at least one exported/annotated column\")\n}","typeGuard":"func hasColumns(t reflect.Type) bool {\n    return t.Kind() == reflect.Struct && t.NumField() > 0\n}","tryCatchPattern":"func safeRead(s beam.Scope, proj, ds, tbl string, t reflect.Type) (pc beam.PCollection, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"bigqueryio.Read failed: %v\", r)\n        }\n    }()\n    return bigqueryio.Read(s, proj, ds, tbl, t), nil\n}","preventionTips":["Ensure row structs use exported fields.","Verify struct tags match the tagKey so fields are inferred as columns."],"tags":["go","apache-beam","bigquery"],"backgroundTag":"schema-validation-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"}