Skip to content

Commit bbef621

Browse files
authored
[hotfix][pipeline-connector][mysql] Fix missed optional option in MySqlDataSourceFactory
This closes #3867
1 parent e81df94 commit bbef621

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/main/java/org/apache/flink/cdc/connectors/mysql/factory/MySqlDataSourceFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ public Set<ConfigOption<?>> optionalOptions() {
335335
options.add(METADATA_LIST);
336336
options.add(INCLUDE_COMMENTS_ENABLED);
337337
options.add(USE_LEGACY_JSON_FORMAT);
338+
options.add(TREAT_TINYINT1_AS_BOOLEAN_ENABLED);
338339
return options;
339340
}
340341

flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/test/java/org/apache/flink/cdc/connectors/mysql/source/MySqlDataSourceFactoryTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.SCAN_INCREMENTAL_SNAPSHOT_CHUNK_KEY_COLUMN;
4444
import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.TABLES;
4545
import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.TABLES_EXCLUDE;
46+
import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.TREAT_TINYINT1_AS_BOOLEAN_ENABLED;
4647
import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.USERNAME;
4748
import static org.apache.flink.cdc.connectors.mysql.source.config.MySqlSourceOptions.SCAN_NEWLY_ADDED_TABLE_ENABLED;
4849
import static org.apache.flink.cdc.connectors.mysql.testutils.MySqSourceTestUtils.TEST_PASSWORD;
@@ -245,6 +246,28 @@ public void testUnsupportedOption() {
245246
+ "unsupported_key");
246247
}
247248

249+
@Test
250+
public void testOptionalOption() {
251+
inventoryDatabase.createAndInitialize();
252+
Map<String, String> options = new HashMap<>();
253+
options.put(HOSTNAME.key(), MYSQL_CONTAINER.getHost());
254+
options.put(PORT.key(), String.valueOf(MYSQL_CONTAINER.getDatabasePort()));
255+
options.put(USERNAME.key(), TEST_USER);
256+
options.put(PASSWORD.key(), TEST_PASSWORD);
257+
options.put(TABLES.key(), inventoryDatabase.getDatabaseName() + ".prod\\.*");
258+
259+
// optional option
260+
options.put(TREAT_TINYINT1_AS_BOOLEAN_ENABLED.key(), "false");
261+
262+
Factory.Context context = new MockContext(Configuration.fromMap(options));
263+
MySqlDataSourceFactory factory = new MySqlDataSourceFactory();
264+
assertThat(factory.optionalOptions().contains(TREAT_TINYINT1_AS_BOOLEAN_ENABLED))
265+
.isEqualTo(true);
266+
267+
MySqlDataSource dataSource = (MySqlDataSource) factory.createDataSource(context);
268+
assertThat(dataSource.getSourceConfig().isTreatTinyInt1AsBoolean()).isEqualTo(false);
269+
}
270+
248271
@Test
249272
public void testPrefixRequireOption() {
250273
inventoryDatabase.createAndInitialize();

0 commit comments

Comments
 (0)