@Test
public void testStatsTrendActionTextFieldNested() throws FoxtrotException {

    StatsTrendRequest request = new StatsTrendRequest();
    request.setTable(TestUtils.TEST_TABLE_NAME);
    request.setTimestamp("_timestamp");
    request.setField("os");
    request.setNesting(ImmutableList.of("os", "device"));
    request.setStats(Collections.singleton(Stat.AVG));
    BetweenFilter betweenFilter = new BetweenFilter();
    betweenFilter.setFrom(1L);
    betweenFilter.setTo(System.currentTimeMillis());
    betweenFilter.setTemporal(true);
    betweenFilter.setField("_timestamp");
    request.setFilters(Collections.singletonList(betweenFilter));
    StatsTrendResponse statsTrendResponse = StatsTrendResponse.class.cast(getQueryExecutor().execute(request));
    try {
        System.out.println(Jackson.newObjectMapper()
                                   .writerWithDefaultPrettyPrinter()
                                   .writeValueAsString(statsTrendResponse));
    }
    catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    assertNull(statsTrendResponse.getResult());
    assertNotNull(statsTrendResponse.getBuckets());
    //No clean way to validate this .. gonna wing it
    Assert.assertNull(statsTrendResponse.getBuckets().get(0).getResult());
    Assert.assertNotNull(statsTrendResponse.getBuckets().get(0).getBuckets());
    //android-nexus
    Assert.assertEquals(1L,
                        statsTrendResponse.getBuckets().get(0).getBuckets().get(0).getResult().get(0).getStats().get("count"));
    //Make sure  few of them are actually zero
    Assert.assertEquals(0L,
                        statsTrendResponse.getBuckets().get(0).getBuckets().get(0).getResult().get(2).getStats().get("count"));
    Assert.assertEquals(0L,
                        statsTrendResponse.getBuckets().get(0).getBuckets().get(0).getResult().get(12).getStats().get("count"));
    //Now data should come
    Assert.assertEquals(1L,
                        statsTrendResponse.getBuckets().get(0).getBuckets().get(0).getResult().get(13).getStats().get("count"));
    //ios-galaxy
    Assert.assertEquals(1L,
                        statsTrendResponse.getBuckets().get(1).getBuckets().get(0).getResult().get(0).getStats().get("count"));
    //ios-nexus
    Assert.assertEquals(1L,
                        statsTrendResponse.getBuckets().get(1).getBuckets().get(1).getResult().get(0).getStats().get("count"));
    //wp
    Assert.assertEquals(1L,
                        statsTrendResponse.getBuckets().get(2).getBuckets().get(0).getResult().get(0).getStats().get("count"));
}