apache/beam · error

unable to provide schema.LogicalType for type %v, want %v

Error message

unable to provide schema.LogicalType for type %v, want %v

What it means

callableSourceProvider.FromLogicalType can only convert the specific PythonCallableSource logical type (pcsType); any other reflect.Type is unsupported and returns this error. It is part of the xlang Python external type mapping. Callers should only invoke this provider for the expected logical type.

Source

Thrown at sdks/go/pkg/beam/transforms/xlang/python/external.go:84

//
//	import math
//
//	def helper(x):
//	    return x * x
//
//	def func(y):
//	    return helper(y) + y
//
// in which case `func` would get applied to each element.
type CallableSource string

// callableSourceProvider implement the SchemaProvider interface for logical types
type callableSourceProvider struct{}

// FromLogicalType returns the goType of the logical type
func (p *callableSourceProvider) FromLogicalType(rt reflect.Type) (reflect.Type, error) {
	if rt != pcsType {
		return nil, fmt.Errorf("unable to provide schema.LogicalType for type %v, want %v", rt, pcsType)
	}
	return pcsStorageType, nil
}

// BuildEncoder encodes the PythonCallableSource logical type
func (p *callableSourceProvider) BuildEncoder(rt reflect.Type) (func(any, io.Writer) error, error) {
	if _, err := p.FromLogicalType(rt); err != nil {
		return nil, err
	}

	return func(iface any, w io.Writer) error {
		v := iface.(CallableSource)
		return coder.EncodeStringUTF8(string(v), w)
	}, nil
}

// BuildDecoder decodes the PythonCallableSource logical type
func (p *callableSourceProvider) BuildDecoder(rt reflect.Type) (func(io.Reader) (any, error), error) {

View on GitHub (pinned to 12126d8942)

Solutions

  1. Ensure the logical type is registered only for PythonCallableSource's type
  2. Check that the URN/type pairing in the pipeline payload matches the Go provider
  3. Return this error from your own FromLogicalType only for unmatched types
  4. Update Beam versions on both sides so logical type identifiers agree

Example fix

// before
provider.FromLogicalType(reflect.TypeOf(MyType{})) // wrong type
// after
provider.FromLogicalType(pcsType) // the PythonCallableSource type
Defensive patterns

Strategy: try-catch

Validate before calling

if rt != pcsType {
    return fmt.Errorf("unsupported logical type %v", rt)
}

Try / catch

rt, err := provider.FromLogicalType(lt)
if err != nil {
    return nil, fmt.Errorf("logical type resolution: %w", err)
}

Prevention

When it happens

Trigger: schema.LogicalType resolution calls FromLogicalType with a reflect.Type other than the registered pcsType — usually from a mismatched or hand-constructed logical type registration.

Common situations: Manually registering the provider against the wrong Go type; version drift between the Python-side logical type URN and the Go provider.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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