From 1ff8d3ec596dc9aebe4d402f6f90902e182ff70e Mon Sep 17 00:00:00 2001 From: Ada Wang Date: Fri, 20 May 2022 13:50:39 +0800 Subject: [PATCH] [FLINK-27711][python][connector/pulsar] Fix the typo of the method name from set_topics_pattern to set_topic_pattern This closes #19774. --- flink-python/pyflink/datastream/connectors/pulsar.py | 10 ++++++++++ .../pyflink/datastream/tests/test_connectors.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/flink-python/pyflink/datastream/connectors/pulsar.py b/flink-python/pyflink/datastream/connectors/pulsar.py index 89557dbdd77a5..e3c4da96d784d 100644 --- a/flink-python/pyflink/datastream/connectors/pulsar.py +++ b/flink-python/pyflink/datastream/connectors/pulsar.py @@ -311,9 +311,19 @@ def set_topics_pattern(self, topics_pattern: str) -> 'PulsarSourceBuilder': Set a topic pattern to consume from the java regex str. You can set topics once either with setTopics or setTopicPattern in this builder. """ + warnings.warn("set_topics_pattern is deprecated. Use set_topic_pattern instead.", + DeprecationWarning, stacklevel=2) self._j_pulsar_source_builder.setTopicPattern(topics_pattern) return self + def set_topic_pattern(self, topic_pattern: str) -> 'PulsarSourceBuilder': + """ + Set a topic pattern to consume from the java regex str. You can set topics once either with + setTopics or setTopicPattern in this builder. + """ + self._j_pulsar_source_builder.setTopicPattern(topic_pattern) + return self + def set_start_cursor(self, start_cursor: StartCursor) -> 'PulsarSourceBuilder': """ Specify from which offsets the PulsarSource should start consume from by providing an diff --git a/flink-python/pyflink/datastream/tests/test_connectors.py b/flink-python/pyflink/datastream/tests/test_connectors.py index 1493ccbf072b6..b814405a0b030 100644 --- a/flink-python/pyflink/datastream/tests/test_connectors.py +++ b/flink-python/pyflink/datastream/tests/test_connectors.py @@ -242,7 +242,7 @@ def test_source_set_topics_pattern(self): PulsarSource.builder() \ .set_service_url('pulsar://localhost:6650') \ .set_admin_url('http://localhost:8080') \ - .set_topics_pattern('ada.*') \ + .set_topic_pattern('ada.*') \ .set_subscription_name('ff') \ .set_deserialization_schema( PulsarDeserializationSchema.flink_schema(SimpleStringSchema())) \ @@ -254,7 +254,7 @@ def test_source_deprecated_method(self): pulsar_source = PulsarSource.builder() \ .set_service_url('pulsar://localhost:6650') \ .set_admin_url('http://localhost:8080') \ - .set_topics('ada') \ + .set_topics_pattern('ada.*') \ .set_deserialization_schema( PulsarDeserializationSchema.flink_type_info(Types.STRING(), None)) \ .set_subscription_name('ff') \