You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beam.apache.org by ed...@gmail.com, ed...@gmail.com on 2018/06/18 21:10:33 UTC

Go SDK: bad parameter type for reflect.methodValueCall: func(Record)

I have the following code:

type Record struct {
       Timestamp time.Time
       Payload   string
}

type processFn struct {
        // etc...
}

func (f *processFn) ProcessElement(ctx context.Context, data []byte, emit func(Record)) {
         // etc..
         emit(someRecord)
         // etc...
}

Which is eventually invoked as:
beam.ParDo(scope, &processFn{}, pcoll)

This seems to work fine using the direct runner until I add a map to the Record struct as follows:

type Record struct {
        Timestamp    time.Time
        Payload      string
        Labels       map[string]string
}

Then I get the error mentioned in the subject line.

My questions are:
- Are maps illegal? What is a legal structure? or
- Is the feature yet to be implemented? or
- Am I doing something wrong? Am I failing to setup my pipeline correctly?
	
Thanks for your help.

Re: Go SDK: bad parameter type for reflect.methodValueCall: func(Record)

Posted by Henning Rohde <he...@google.com>.
Hi Eduardo,

 You're not doing anything wrong. Maps are currently not classified as a
valid data type by the type checker, but perhaps they should be.


https://github.com/apache/beam/blob/6889792b994e1418ae73940198eb8767950287b5/sdks/go/pkg/beam/core/typex/class.go#L97

Please feel free to open a bug. As a less-than-convenient workaround, you
can use a slice.

Thanks,
 Henning

On Mon, Jun 18, 2018 at 2:10 PM eduardo.morales@gmail.com <
eduardo.morales@gmail.com> wrote:

> I have the following code:
>
> type Record struct {
>        Timestamp time.Time
>        Payload   string
> }
>
> type processFn struct {
>         // etc...
> }
>
> func (f *processFn) ProcessElement(ctx context.Context, data []byte, emit
> func(Record)) {
>          // etc..
>          emit(someRecord)
>          // etc...
> }
>
> Which is eventually invoked as:
> beam.ParDo(scope, &processFn{}, pcoll)
>
> This seems to work fine using the direct runner until I add a map to the
> Record struct as follows:
>
> type Record struct {
>         Timestamp    time.Time
>         Payload      string
>         Labels       map[string]string
> }
>
> Then I get the error mentioned in the subject line.
>
> My questions are:
> - Are maps illegal? What is a legal structure? or
> - Is the feature yet to be implemented? or
> - Am I doing something wrong? Am I failing to setup my pipeline correctly?
>
> Thanks for your help.
>