eskabetxe commented on code in PR #180:
URL:
https://github.com/apache/flink-connector-jdbc/pull/180#discussion_r3213109436
##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/core/datastream/source/JdbcSourceBuilder.java:
##########
@@ -289,36 +302,52 @@ public JdbcSource<OUT> build() {
JdbcSourceOptions.READER_FETCH_BATCH_SIZE,
splitReaderFetchBatchSize);
this.configuration.set(JdbcSourceOptions.AUTO_COMMIT, autoCommit);
- Preconditions.checkState(
- !StringUtils.isNullOrWhitespaceOnly(sql), "'sql' mustn't be
null or empty.");
Preconditions.checkNotNull(resultExtractor, "'resultExtractor' mustn't
be null.");
Preconditions.checkNotNull(typeInformation, "'typeInformation' mustn't
be null.");
- if (Objects.nonNull(continuousUnBoundingSettings)) {
- Preconditions.checkArgument(
- Objects.nonNull(jdbcParameterValuesProvider)
- && jdbcParameterValuesProvider
- instanceof
JdbcSlideTimingParameterProvider,
- INVALID_SLIDE_TIMING_CONTINUOUS_HINT);
- }
-
- if (Objects.nonNull(jdbcParameterValuesProvider)
- && jdbcParameterValuesProvider instanceof
JdbcSlideTimingParameterProvider) {
- Preconditions.checkArgument(
- Objects.nonNull(continuousUnBoundingSettings),
- INVALID_CONTINUOUS_SLIDE_TIMING_HINT);
+ if (this.splitterEnumerator == null) {
Review Comment:
done
##########
flink-connector-jdbc-core/src/test/java/org/apache/flink/connector/jdbc/core/datastream/source/enumerator/splitter/PreparedSplitterNumericParametersTest.java:
##########
@@ -0,0 +1,116 @@
+package
org.apache.flink.connector.jdbc.core.datastream.source.enumerator.splitter;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.Serializable;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class PreparedSplitterNumericParametersTest {
+
+ @Test
+ void testBatchSizeDivisible() {
+ Serializable[][] parameters =
+ new PreparedSplitterNumericParameters(-5,
9).withBatchSize(3).getParameterValues();
+
+ long[][] expected = {
+ new long[] {-5, -3},
+ new long[] {-2, 0},
+ new long[] {1, 3},
+ new long[] {4, 6},
+ new long[] {7, 9}
+ };
+ check(expected, parameters);
+ }
+
+ @Test
+ void testBatchSizeNotDivisible() {
+ Serializable[][] parameters =
+ new PreparedSplitterNumericParameters(-5,
11).withBatchSize(4).getParameterValues();
+
+ long[][] expected = {
+ new long[] {-5, -2},
+ new long[] {-1, 2},
+ new long[] {3, 5},
+ new long[] {6, 8},
+ new long[] {9, 11}
+ };
+ check(expected, parameters);
+ }
+
+ @Test
+ void testBatchSizeTooLarge() {
+ Serializable[][] parameters =
+ new PreparedSplitterNumericParameters(0,
2).withBatchSize(5).getParameterValues();
+
+ long[][] expected = {new long[] {0, 2}};
+ check(expected, parameters);
+ }
+
+ @Test
+ void testBatchNumDivisible() {
+ Serializable[][] parameters =
+ new PreparedSplitterNumericParameters(-5,
9).withBatchNum(5).getParameterValues();
+
+ long[][] expected = {
+ new long[] {-5, -3},
+ new long[] {-2, 0},
+ new long[] {1, 3},
+ new long[] {4, 6},
+ new long[] {7, 9}
+ };
+ check(expected, parameters);
+ }
+
+ @Test
+ void testBatchNumNotDivisible() {
+ Serializable[][] parameters =
+ new PreparedSplitterNumericParameters(-5,
11).withBatchNum(5).getParameterValues();
+
+ long[][] expected = {
+ new long[] {-5, -2},
+ new long[] {-1, 2},
+ new long[] {3, 5},
+ new long[] {6, 8},
+ new long[] {9, 11}
+ };
+ check(expected, parameters);
+ }
+
+ @Test
+ void testBatchNumTooLarge() {
+ Serializable[][] parameters =
+ new PreparedSplitterNumericParameters(0,
2).withBatchNum(5).getParameterValues();
+
+ long[][] expected = {
+ new long[] {0, 0},
+ new long[] {1, 1},
+ new long[] {2, 2}
+ };
+ check(expected, parameters);
+ }
+
+ @Test
+ void testBatchMaxMinTooLarge() {
+ Serializable[][] parameters =
+ new PreparedSplitterNumericParameters(2260418954055131340L,
3875220057236942850L)
+ .withBatchNum(3)
+ .getParameterValues();
+
+ long[][] expected = {
+ new long[] {2260418954055131340L, 2798685988449068491L},
+ new long[] {2798685988449068492L, 3336953022843005643L},
+ new long[] {3336953022843005644L, 3875220057236942795L}
Review Comment:
fixed
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]