xuzhiwen1255 commented on code in PR #21971: URL: https://github.com/apache/flink/pull/21971#discussion_r1119521354
########## flink-table/flink-table-api-java-bridge/src/test/java/org/apache/flink/table/factories/DataGenTableSourceFactoryTest.java: ########## @@ -264,7 +267,68 @@ void testSequenceCheckpointRestore() throws Exception { } @Test - void testLackStartForSequence() { + void testDefaultValueForSequence() { + DescriptorProperties descriptor = new DescriptorProperties(); + descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen"); + descriptor.putString( + DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, + DataGenConnectorOptionsUtil.SEQUENCE); + + DataGenTableSource source = + (DataGenTableSource) + createTableSource( + ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), + descriptor.asMap()); + DataGenerator<?>[] fieldGenerators = source.getFieldGenerators(); + SequenceGenerator<?> fieldGenerator = (SequenceGenerator<?>) fieldGenerators[0]; + long start = fieldGenerator.getStart(); + long end = fieldGenerator.getEnd(); + + Assertions.assertThat(0) + .describedAs("The default start value should be 0") + .isEqualTo(start); + Assertions.assertThat(Integer.MAX_VALUE) + .describedAs("The default start value should be Integer.MAX_VALUE") + .isEqualTo(end); + } + + @Test + void testStartEndForSequence() { + DescriptorProperties descriptor = new DescriptorProperties(); + descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen"); + descriptor.putString( + DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, + DataGenConnectorOptionsUtil.SEQUENCE); + final int setupStart = 10; + descriptor.putLong( + DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.START, + setupStart); + final int setupEnd = 100; + descriptor.putLong( + DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.END, + setupEnd); + + DataGenTableSource source = + (DataGenTableSource) + createTableSource( + ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), + descriptor.asMap()); + DataGenerator<?>[] fieldGenerators = source.getFieldGenerators(); + SequenceGenerator<?> fieldGenerator = (SequenceGenerator<?>) fieldGenerators[0]; + long start = fieldGenerator.getStart(); + long end = fieldGenerator.getEnd(); + + Assertions.assertThat(setupStart) + .describedAs("The default start value should be " + setupStart) + .isEqualTo(start); + Assertions.assertThat(setupEnd) + .describedAs("The default start value should be " + setupEnd) + .isEqualTo(end); + } + + @Test + void testCornerCaseForSequence() { + // An example of testing that the end value is greater than the start value Review Comment: Added a new test case, has been modified. -- 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. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org