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

[FLINK-28022][python] Support Google Cloud PubSub connector in Python DataStream API #20627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pengmide
Copy link
Contributor

What is the purpose of the change

Improve the documentation by adding Python examples.

Brief change log

  • Introduces the PubSubSource and PubSubSink to support source and sink of pubsub connector in PyFlink.

Verifying this change

  • Adds the PubSubTest to verify the PubSubSource and PubSubSink.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@pengmide
Copy link
Contributor Author

@dianfu Could you review for me? Thanks a lot!

@flinkbot
Copy link
Collaborator

flinkbot commented Aug 19, 2022

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@dianfu dianfu left a comment

Choose a reason for hiding this comment

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

@pengmide Thanks very much for the PR. Very sorry for the late response.

@@ -101,4 +101,40 @@ under the License.
<scope>test</scope>
</dependency>
</dependencies>

<build>
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to add a module flink-sql-connector-gcp-pubsub and move the following logic there.

deserialization_schema._j_serialization_schema)
return PubSubSink.ProjectNameBuilder(_j_serialization_schema)

class ProjectNameBuilder(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not call it PubSubSinkBuilder just as the Java API?

_j_project_name = self._j_project_name_builder.withProjectName(project_name)
return PubSubSink.TopicNameBuilder(_j_project_name)

class TopicNameBuilder(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to merge it with PubSubSinkBuilder and call it PubSubSinkBuilder

"""
JEmulatorCredentialsProvider = get_gateway().jvm. \
org.apache.flink.streaming.connectors.gcp.pubsub.emulator.EmulatorCredentialsProvider
return Credentials(JEmulatorCredentialsProvider.create().getCredentials())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return Credentials(JEmulatorCredentialsProvider.create().getCredentials())
return Credentials(JEmulatorCredentials.getInstance())?

@@ -73,6 +73,13 @@ def _install():
setattr(connectors, 'StreamFormat', file_system.StreamFormat)
setattr(connectors, 'StreamingFileSink', file_system.StreamingFileSink)

# pubsub
from pyflink.datastream.connectors import pubsub
Copy link
Contributor

Choose a reason for hiding this comment

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

This is for backward compatibility. Since pubsub is newly introduced, so this is not necessary and could be removed.

Besides, we may need to add some documentation here: https://github.com/apache/flink/blob/master/flink-python/pyflink/datastream/__init__.py#L209

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.

3 participants