Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-8612

Convert []beam.T to the underlying type []T when passed to a DoFn with universal typed (beam.X) input

Details

    • New Feature
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • None
    • Not applicable
    • sdk-go
    • None

    Description

      Say there are two DoFn: f1, f2.

      • f1 declares the output type as []beam.T, and each element has the underlying type int.
      • f2 declares the input type as []int

      Passing f1 output to f2 works well. The conversion from []beam.T to []int happens at: https://github.com/apache/beam/blob/c7be0643934a87d73483cf1fd3199a425508b03c/sdks/go/pkg/beam/core/runtime/exec/fullvalue.go#L108

      But it doesn't work if f2 declares the input type as beam.X and type casts it to []int. This is because there's no type conversion when passing []beam.T to beam.X.

      We may consider supporting the above case by converting []beam.T to the underlying type []T when it's passed to a universal type.

      An issue is that if []beam.T is nil or empty, we don't know its underlying element type (unless we know which concrete type beam.T or beam.X is bound to, but this mapping doesn't seem to be kept at runtime?). In such case, we have to pass []beam.T to beam.X as is.

      Attachments

        Issue Links

          Activity

            People

              htyleo Tianyang Hu
              htyleo Tianyang Hu
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h