apache/beam · error
bigqueryio.Read: type
Error message
bigqueryio.Read: type %v has no columns to select
What it means
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.
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.
Example fix
// before
type row struct { name string } // unexported: no columns
beam.ParDo0(s, ..., ) ; bigqueryio.Read(s, project, "dataset", "table", reflect.TypeOf(row{}))
// after
type row struct { Name string `bigquery:"name"` } Defensive patterns
Strategy: validation
Validate before calling
t := reflect.TypeOf(row{})
if t.Kind() != reflect.Struct || structx.InferFieldNames(t, "bigquery") == nil || len(structx.InferFieldNames(t, "bigquery")) == 0 {
return errors.New("row type must have at least one exported/annotated column")
} Type guard
func hasColumns(t reflect.Type) bool {
return t.Kind() == reflect.Struct && t.NumField() > 0
} Try / catch
func safeRead(s beam.Scope, proj, ds, tbl string, t reflect.Type) (pc beam.PCollection, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("bigqueryio.Read failed: %v", r)
}
}()
return bigqueryio.Read(s, proj, ds, tbl, t), nil
} Prevention
- Ensure row structs use exported fields.
- Verify struct tags match the tagKey so fields are inferred as columns.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- err
- invalid schema type
- requires either a Table or Query specified, received none
- A BigQuery table or a query must be specified
- A function must be provided to convert the input type into…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/581a31a2f7e9d92d.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/io/bigqueryio/bigquery.go:105
// Read reads all rows from the given table. The table must have a schema
// compatible with the given type, t, and Read returns a PCollection<t>. If the
// table has more rows than t, then Read is implicitly a projection.
func Read(s beam.Scope, project, table string, t reflect.Type) beam.PCollection {
mustParseTable(table)
s = s.Scope("bigquery.Read")
stmt := constructSelectStatement(t, bigQueryTag, table)
return query(s, project, stmt, t)
}
func constructSelectStatement(t reflect.Type, tagKey string, table string) string {
columns := structx.InferFieldNames(t, tagKey)
if len(columns) == 0 {
panic(fmt.Sprintf("bigqueryio.Read: type %v has no columns to select", t))
}
columnStr := strings.Join(columns, ", ")
return fmt.Sprintf("SELECT %v FROM [%v]", columnStr, table)
}
// QueryOptions represents additional options for executing a query.
type QueryOptions struct {
// UseStandardSQL enables BigQuery's Standard SQL dialect when executing a query.
UseStandardSQL bool
// Parameters are the query parameters for parameterized queries.
// In the current implementation, user-defines types are not supported in Value field.
// Use *bigquery.QueryParameterValue to build STRUCT/ARRAY parameters
// or use go primitive types explicitly.
parameters []bigquery.QueryParameter
}
View on GitHub (pinned to 12126d8942)