Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve pane index through reshuffle. #34348

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

claudevdm
Copy link
Collaborator


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@claudevdm claudevdm requested a review from kennknowles March 24, 2025 17:30
@claudevdm claudevdm marked this pull request as ready for review March 25, 2025 14:53
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @shunping for label python.
R: @jrmccluskey for label go.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@@ -124,6 +124,7 @@ var (
CoderTimer = cdrUrn(pipepb.StandardCoders_TIMER)

CoderKV = cdrUrn(pipepb.StandardCoders_KV)
CoderTuple = "beam:coder:tuple:v1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems suspiciously out of place, being a magic string and also not a standard coder. What is the story behind it?

Copy link
Collaborator Author

@claudevdm claudevdm Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I placed it here because python switches between tuple coder depending on number of elements which cauuses python tests to fail with prism runner

if self.is_kv_coder():

For example, with the pane index change there ends up being a tuple coder with 3 elements (because pane info is now included)

coders {
    key: "ref_Coder_TupleCoder_6"
    value {
      spec {
        urn: "beam:coder:tuple:v1"
      }
      component_coder_ids: "ref_Coder_BytesCoder_1"
      component_coder_ids: "ref_Coder_NullableCoder_7"
      component_coder_ids: "ref_Coder_FastPrimitivesCoder_8"
    }
  }

But without pane info it falls back to using KV coder which is supported by prism

coders {
    key: "ref_Coder_TupleCoder_6"
    value {
      spec {
        urn: "beam:coder:kv:v1"
      }
      component_coder_ids: "ref_Coder_BytesCoder_1"
      component_coder_ids: "ref_Coder_NullableCoder_7"
    }
  }

Prism error without this change:
ERROR:root:prism error building stage stage-002:
unknown coder urn key: beam:coder:tuple:v1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like something we probably need to fix another way. The actual shuffle needs KVs, with everything we want to preserve reified into the value component.

Copy link
Collaborator Author

@claudevdm claudevdm Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual shuffle needs KVs

What do you mean by this? The way I understand it is

I guess if we want to avoid this we can have a nested kv in ReifyMetedata so it is

  • key, (value, (timestamp, pane_info))
    Then the regular kv coder should work?
    Or can we also use windowed_value as the value in the reify output instead of a tuple with the medatada?

The original reify just used a kv as the value in the reify function

return key, (value, timestamp)

We are now including pane info as mentioned above so it becomes a tuple

This only happens for global window case, in the custom window case the value for reify is a windowed value

return key, windowed_value.WindowedValue(value, timestamp, [window])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yea KV(key, (value, timestamp, pane_info) should be fine. The runner should not need to have any understanding of the coder for (value, timestamp, pane_info) since that is in general user type / coder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why it came up vs "just working" like you'd expect with other KV(key, whatever) objects. The process of submitting portably should result in a length-prefix coder wrapper if needed so the runner can just pass the bytes through.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unkown coders are only legth prefixed if they are "leaf" and no sub-components coders. The tuple coder has sub components, so it is not length prefixed

// If we don't know this coder, and it has no sub components,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chatted with Rebo who said componentizable coders do not play nicely with runner side length prefixing. He said adding a tuple coder is the right move here, and since Python isn't planning on getting rid of it (?) we might want to make it documented as a standard coder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants