@Test
  public void testSubQueryInSubView() throws Exception {
    String prefix = "tvsubqueryinsubview" + NAME_PREFIX;
    final String tab1 = prefix + "t";
    final String view1 = prefix + "v";
    final String view2 = prefix + "v2";

    driver.run("create table " + tab1 + "(id int)");
    driver.run("create view " + view1 + " as select * from " + tab1);

    driver.run("create view " + view2 + " as select * from (select * from " + view1 + ") x");

    driver.compile("select * from " + view2, true);
    // view entity
    assertEquals("default@" + view2, CheckInputReadEntity.readEntities[0].getName());

    // table1 and view1 as second read entity
    assertEquals("default@" + view1, CheckInputReadEntity.readEntities[1].getName());
    assertFalse("Table is not direct input", CheckInputReadEntity.readEntities[1].isDirect());
    Set<ReadEntity> parents = CheckInputReadEntity.readEntities[1].getParents();
    assertTrue("Table does not have parent", parents != null && parents.size() > 0);
    assertEquals("default@" + tab1, CheckInputReadEntity.readEntities[2].getName());
    assertFalse("Table is not direct input", CheckInputReadEntity.readEntities[2].isDirect());

  }
Verify that the the query with the subquery inside a view will have the correct
direct and indirect inputs.
@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java