[
https://issues.apache.org/jira/browse/BEAM-7738?focusedWorklogId=332181&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332181
]
ASF GitHub Bot logged work on BEAM-7738:
----------------------------------------
Author: ASF GitHub Bot
Created on: 22/Oct/19 20:19
Start Date: 22/Oct/19 20:19
Worklog Time Spent: 10m
Work Description: TheNeuralBit commented on issue #9268: [BEAM-7738] Add
external transform support to PubsubIO
URL: https://github.com/apache/beam/pull/9268#issuecomment-545135957
> Right now I'm mostly thinking about the latter
Agreed, that's what I'm thinking about too.
> Maybe I'm thinking about this wrong, but I think the PubsubMessage is
structured:
Ah ok, fair. I was referring specifically to the structure (or lack thereof)
of the byte array payload, but you're right the (Python SDK) user can handle
creating a byte array themselves, and the row coder can just encode `{byte[]
payload, Map<String, String> attributes, String messageId}`
> What are the requirements for registering a Row converter?
### Java
There are a variety of ways to do it. If it were a class that we had control
over we could use the
[`DefaultSchema`](https://beam.apache.org/releases/javadoc/2.16.0/org/apache/beam/sdk/schemas/DefaultSchema.html)
annotation, as long as one of the included SchemaProvider implementations
would work (I think JavaBeanSchema is the closest but wouldn't work because
PubsubMessage doesn't have setters). I think what we'd want to do here is just
implement a
[`SchemaProvider`](https://beam.apache.org/releases/javadoc/2.16.0/org/apache/beam/sdk/schemas/SchemaProvider.html)
and a
[`SchemaProviderRegistrar`](https://beam.apache.org/releases/javadoc/2.16.0/org/apache/beam/sdk/schemas/SchemaProviderRegistrar.html)
for `PubsubMessage` and include it in Beam.
@reuvenlax may have a better suggestion.
### Python
With my PR I think it could look like:
```python
# this is py3 syntax for clarity, but we'd probably
# need to use the TypedDict('PubsubMessage', ...) version
class PubsubMessage(TypedDict):
message: ByteString
attributes: Mapping[unicode, unicode]
messageId: unicode
coders.registry.register_coder(PubsubMessage, coders.RowCoder)
pcoll
| 'make some messages' >>
beam.Map(makeMessage).with_output_types(PubsubMessage)
| 'write to pubsub' >> beam.io.WriteToPubsub(project, topic) # or something
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 332181)
Time Spent: 7h 20m (was: 7h 10m)
> Support PubSubIO to be configured externally for use with other SDKs
> --------------------------------------------------------------------
>
> Key: BEAM-7738
> URL: https://issues.apache.org/jira/browse/BEAM-7738
> Project: Beam
> Issue Type: New Feature
> Components: io-java-gcp, runner-flink, sdk-py-core
> Reporter: Chad Dombrova
> Assignee: Chad Dombrova
> Priority: Major
> Labels: portability
> Time Spent: 7h 20m
> Remaining Estimate: 0h
>
> Now that KafkaIO is supported via the external transform API (BEAM-7029) we
> should add support for PubSub.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)