private void testViewInSubQueryWithWhereClause() throws CommandProcessorException {
    String prefix = "tvsubquerywithwhereclause" + NAME_PREFIX;
    final String tab1 = prefix + "t";
    final String view1 = prefix + "v";
    final String view2 = prefix + "v2";
    final String tab1row1 = "'x','y','z'";
    final String tab1row2 = "'a','b','c'";

    //drop all if exists
    driver.run("drop table if exists " + tab1);
    driver.run("drop view if exists " + view1);
    driver.run("drop view if exists " + view2);

    //create tab1
    driver.run("create table " + tab1 + "(col1 string, col2 string, col3 string)");
    driver.run("insert into " + tab1 + " values (" + tab1row1 + ")");

    //create view1
    driver.run("create view " + view1 + " as select " +
        tab1 + ".col1, " + tab1 + ".col2, " + tab1 + ".col3 " +
        " from " + tab1);

    driver.run("insert into " + tab1 + " values (" + tab1row2 + ")");

    //create view2
    driver.run(
        "create view " + view2 + " as select " +
            tab1 + ".col1, " + tab1 + ".col2, " + tab1 + ".col3 " +
            " from " + tab1 +
            " where " + tab1 + ".col1 NOT IN (" +
            "SELECT " + view1 + ".col1 FROM " + view1 + ")");

    //select from view2
    driver.compile("select * from " + view2, true);

    //verify that only view2 is direct input in above query
    ReadEntity[] readEntities = CheckInputReadEntity.readEntities;
    for (ReadEntity readEntity : readEntities) {
      String name = readEntity.getName();
      if (name.equals("default@" + tab1)) {
        assertFalse("Table should not be direct input", readEntity.isDirect());
      } else if (name.equals("default@" + view1)) {
        assertFalse("View1 should not be direct input", readEntity.isDirect());
      } else if (name.equals("default@" + view2)) {
        assertTrue("View2 should be direct input", readEntity.isDirect());
      } else {
        fail("Unrecognized ReadEntity input");
      }
    }
  }
Verify that the parent entities are captured correctly for view in subquery with WHERE
subquery referencing a view. Optimizer: Rule-based

@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java