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

Label Python external SchemaTransform with its URN #28540

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions sdks/python/apache_beam/transforms/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ def __init__(self, identifier, **kwargs):
self._identifier = identifier
self._kwargs = kwargs

def identifier(self):
"""
The URN referencing this SchemaTransform

:return: str
"""
return self._identifier

def build(self):
schema_proto, payload = self._get_schema_proto_and_payload(**self._kwargs)
payload = external_transforms_pb2.SchemaTransformPayload(
Expand All @@ -194,7 +202,7 @@ def build(self):
return payload


class ExplicitSchemaTransformPayloadBuilder(PayloadBuilder):
class ExplicitSchemaTransformPayloadBuilder(SchemaTransformPayloadBuilder):
def __init__(self, identifier, schema_proto, **kwargs):
self._identifier = identifier
self._schema_proto = schema_proto
Expand Down Expand Up @@ -414,7 +422,7 @@ def __init__(

def expand(self, pcolls):
# Expand the transform using the expansion service.
return pcolls | ExternalTransform(
return pcolls | self._payload_builder.identifier() >> ExternalTransform(
common_urns.schematransform_based_expand.urn,
self._payload_builder,
self._expansion_service)
Expand Down
Loading