fsk119 commented on a change in pull request #12908:
URL: https://github.com/apache/flink/pull/12908#discussion_r462161021
##########
File path:
flink-connectors/flink-connector-kafka-base/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaDynamicTableFactoryTestBase.java
##########
@@ -187,6 +197,62 @@ public void testTableSourceCommitOnCheckpointsDisabled() {
assertFalse(((FlinkKafkaConsumerBase)
function).getEnableCommitOnCheckpoints());
}
+ @Test
+ public void testTableSourceWithPattern() {
+ // prepare parameters for Kafka table source
+ final DataType producedDataType =
SOURCE_SCHEMA.toPhysicalRowDataType();
+
+ final Map<KafkaTopicPartition, Long> specificOffsets = new
HashMap<>();
+
+ DecodingFormat<DeserializationSchema<RowData>> decodingFormat =
+ new TestFormatFactory.DecodingFormatMock(",", true);
+
+ // Construct table source using options and table source factory
+ ObjectIdentifier objectIdentifier = ObjectIdentifier.of(
+ "default",
+ "default",
+ "scanTable");
+
+ final Map<String, String> modifiedOptions = getModifiedOptions(
+ getFullSourceOptions(),
+ options -> {
+ options.remove("topic");
+ options.put("topic-pattern", TOPIC_REGEX);
+ options.put("scan.startup.mode",
KafkaOptions.SCAN_STARTUP_MODE_VALUE_EARLIEST);
+ options.remove("scan.startup.specific-offsets");
+ });
+ CatalogTable catalogTable =
createKafkaSourceCatalogTable(modifiedOptions);
+
+ final DynamicTableSource actualSource =
FactoryUtil.createTableSource(null,
+ objectIdentifier,
+ catalogTable,
+ new Configuration(),
+ Thread.currentThread().getContextClassLoader());
+
+ // Test scan source equals
+ final KafkaDynamicSourceBase expectedKafkaSource =
getExpectedScanSource(
+ producedDataType,
+ null,
+ Pattern.compile(TOPIC_REGEX),
+ KAFKA_PROPERTIES,
+ decodingFormat,
+ StartupMode.EARLIEST,
+ specificOffsets,
Review comment:
emm. I think it's more trivial to use a new hashmap to store the option
value. Because we need to add more options such as format.
----------------------------------------------------------------
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]