apache/beam · error

requires either a Table or Query specified, received none

Error message

%v requires either a Table or Query specified, received none

What it means

bigqueryio.Read in the Beam Go xlang package panics if neither a Table nor a Query option was supplied. The cross-language BigQuery read needs exactly one of these to know what data to fetch, so an empty configuration is rejected at graph-construction time.

Solutions

  1. Pass either bigqueryio.Table("project:dataset.table") or bigqueryio.Query("SELECT ...") as an option.
  2. If the source is chosen dynamically, validate exactly one is set before calling Read and return a clear error instead.
  3. Check that your config-loading code actually populates the table or query value (non-empty string).

Example fix

// before
bigqueryio.Read(s, addr)
// after
bigqueryio.Read(s, addr, bigqueryio.Table("my-project:mydataset.mytable"))
Defensive patterns

Strategy: validation

Validate before calling

func hasBQSource(opts []bigqueryio.ReadOption, table, query string) error {
    if table == "" && query == "" {
        return errors.New("bigqueryio.Read needs either a Table or a Query")
    }
    return nil
}

Prevention

When it happens

Trigger: Calling bigqueryio.Read(s, addr) with no bigqueryio.Table(...) or bigqueryio.Query(...) option in the variadic opts list.

Common situations: Building read options conditionally where both branches were skipped; refactoring away from a positional table argument into options and forgetting to add one; constructing options from config where the table/query key was absent.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/396532f0039a87c0. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/io/xlang/bigqueryio/bigquery.go:152

// within Read's function signature.
//
// Example:
//
//	expansionAddr := "localhost:1234"
//	table := "project_id:dataset_id.table_id"
//	outType := reflect.TypeOf((*Foo)(nil)).Elem()
//	pcol := bigqueryio.Read(s, outType,
//	    bigqueryio.FromTable(table),
//	    bigqueryio.ReadExpansionAddr(expansionAddr))
func Read(s beam.Scope, elmT reflect.Type, opts ...readOption) beam.PCollection {
	s = s.Scope("bigqueryio.Read")

	rc := readConfig{cfg: &bigQueryConfig{}}
	for _, opt := range opts {
		opt(&rc)
	}
	if rc.cfg.Table == nil && rc.cfg.Query == nil {
		panic(fmt.Sprintf("%v requires either a Table or Query specified, received none", s.String()))
	}

	addr := rc.addr
	if addr == "" {
		addr = autoStartupAddress
	}

	pl := schemaio.MustEncodePayload("", rc.cfg, nil)
	outT := typex.New(elmT)
	outs := beam.CrossLanguage(s, readURN, pl, addr, nil, beam.UnnamedOutput(outT))
	return outs[beam.UnnamedOutputTag()]
}

type readConfig struct {
	cfg  *bigQueryConfig
	addr string
}
type readOption func(*readConfig)

View on GitHub (pinned to 12126d8942)