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

    https://github.com/apache/storm/pull/1714#discussion_r80415245
  
    --- Diff: 
external/sql/storm-sql-core/src/test/org/apache/storm/sql/TestStormSql.java ---
    @@ -174,26 +173,42 @@ public void testExternalDataSource() throws Exception 
{
       public void testExternalDataSourceNested() throws Exception {
         List<String> stmt = new ArrayList<>();
         stmt.add("CREATE EXTERNAL TABLE FOO (ID INT, MAPFIELD ANY, 
NESTEDMAPFIELD ANY, ARRAYFIELD ANY) LOCATION 'mocknested:///foo'");
    -    stmt.add("SELECT STREAM ID, MAPFIELD, NESTEDMAPFIELD, ARRAYFIELD " +
    +    stmt.add("SELECT STREAM ID, MAPFIELD['c'], NESTEDMAPFIELD, ARRAYFIELD 
" +
                          "FROM FOO " +
    -                     "WHERE NESTEDMAPFIELD['a']['b'] = 2 AND ARRAYFIELD[1] 
= 200");
    +                     "WHERE CAST(MAPFIELD['b'] AS INTEGER) = 2 AND 
CAST(ARRAYFIELD[1] AS INTEGER) = 200");
         StormSql sql = StormSql.construct();
         List<Values> values = new ArrayList<>();
         ChannelHandler h = new TestUtils.CollectDataChannelHandler(values);
         sql.execute(stmt, h);
         System.out.println(values);
         Map<String, Integer> map = ImmutableMap.of("b", 2, "c", 4);
         Map<String, Map<String, Integer>> nestedMap = ImmutableMap.of("a", 
map);
    -    Assert.assertEquals(new Values(2, map, nestedMap, Arrays.asList(100, 
200, 300)), values.get(0));
    +    Assert.assertEquals(new Values(2, 4, nestedMap, Arrays.asList(100, 
200, 300)), values.get(0));
       }
     
    -  @Test
    +  @Test(expected = RuntimeException.class)
       public void testExternalNestedInvalidAccess() throws Exception {
         List<String> stmt = new ArrayList<>();
    +    // this triggers java.lang.RuntimeException: Cannot convert null to int
         stmt.add("CREATE EXTERNAL TABLE FOO (ID INT, MAPFIELD ANY, 
NESTEDMAPFIELD ANY, ARRAYFIELD ANY) LOCATION 'mocknested:///foo'");
         stmt.add("SELECT STREAM ID, MAPFIELD, NESTEDMAPFIELD, ARRAYFIELD " +
    -                     "FROM FOO " +
    -                     "WHERE NESTEDMAPFIELD['a']['b'] = 2 AND 
ARRAYFIELD['a'] = 200");
    --- End diff --
    
    This is checking invalid array access (array field being accessed by a 
string index instead of integer). Can you keep earlier test case and add a new 
one for the null check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to