[ 
https://issues.apache.org/jira/browse/FLINK-6271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15958918#comment-15958918
 ] 

ASF GitHub Bot commented on FLINK-6271:
---------------------------------------

Github user fpompermaier commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3686#discussion_r110159791
  
    --- Diff: 
flink-connectors/flink-jdbc/src/test/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormatTest.java
 ---
    @@ -180,6 +180,52 @@ public void 
testJDBCInputFormatWithParallelismAndNumericColumnSplitting() throws
                jdbcInputFormat.closeInputFormat();
                Assert.assertEquals(testData.length, recordCount);
        }
    +   @Test
    +   public void 
testJDBCInputFormatWithoutParallelismAndNumericColumnSplitting() throws 
IOException, InstantiationException, IllegalAccessException {
    +           final Long min = new Long(JDBCTestBase.testData[0][0] + "");
    +           final Long max = new 
Long(JDBCTestBase.testData[JDBCTestBase.testData.length - 1][0] + "");
    +           final long fetchSize = max + 1;//generate a single split
    +           ParameterValuesProvider pramProvider = new 
NumericBetweenParametersProvider(fetchSize, min, max);
    +           jdbcInputFormat = JDBCInputFormat.buildJDBCInputFormat()
    +                           .setDrivername(DRIVER_CLASS)
    +                           .setDBUrl(DB_URL)
    +                           
.setQuery(JDBCTestBase.SELECT_ALL_BOOKS_SPLIT_BY_ID)
    +                           .setRowTypeInfo(rowTypeInfo)
    +                           .setParametersProvider(pramProvider)
    +                           
.setResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)
    +                           .finish();
    +
    +           jdbcInputFormat.openInputFormat();
    +           InputSplit[] splits = jdbcInputFormat.createInputSplits(1);
    +           //assert that a single split was generated
    +           Assert.assertEquals(1, splits.length);
    +           int recordCount = 0;
    +           Row row =  new Row(5);
    +           for (int i = 0; i < splits.length; i++) {
    +                   jdbcInputFormat.open(splits[i]);
    +                   while (!jdbcInputFormat.reachedEnd()) {
    +                           Row next = jdbcInputFormat.nextRecord(row);
    +                           if (next == null) {
    +                                   break;
    +                           }
    +                           if(next.getField(0)!=null) { 
Assert.assertEquals("Field 0 should be int", Integer.class, 
next.getField(0).getClass());}
    +                           if(next.getField(1)!=null) { 
Assert.assertEquals("Field 1 should be String", String.class, 
next.getField(1).getClass());}
    +                           if(next.getField(2)!=null) { 
Assert.assertEquals("Field 2 should be String", String.class, 
next.getField(2).getClass());}
    +                           if(next.getField(3)!=null) { 
Assert.assertEquals("Field 3 should be float", Double.class, 
next.getField(3).getClass());}
    +                           if(next.getField(4)!=null) { 
Assert.assertEquals("Field 4 should be int", Integer.class, 
next.getField(4).getClass());}
    +
    +                           for (int x = 0; x < 5; x++) {
    +                                   if(testData[recordCount][x]!=null) {
    --- End diff --
    
    How should I ensure the param validity? Is there any helper class or should 
just throw an IllegalArgumentException? Is there any example I can take as 
reference param handling?


> NumericBetweenParametersProvider NullPinter
> -------------------------------------------
>
>                 Key: FLINK-6271
>                 URL: https://issues.apache.org/jira/browse/FLINK-6271
>             Project: Flink
>          Issue Type: Bug
>          Components: Batch Connectors and Input/Output Formats
>    Affects Versions: 1.2.0
>            Reporter: Flavio Pompermaier
>            Assignee: Flavio Pompermaier
>              Labels: jdbc
>
> creating a NumericBetweenParametersProvider using fetchSize=1000, min=0 and 
> max= 999 fails with a NP



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to