  @Test
  public void testSkipSnowflakeJoinFact() throws LensException {


    String query = "SELECT (dim1 . date) date , sum((f . msr1)) msr1 , (dim2 . name) dim2_name, "
        + "(dim3 . name) dim3_name , (dim4 . name) dim4_name " + "FROM fact f "
        + "INNER JOIN dim1 dim1 ON f.dim1_id = dim1.id " + "INNER JOIN dim2 dim2 ON f.dim2_id = dim2.id "
        + "INNER JOIN dim3 dim3 ON f.dim3_id = dim3.id " + "INNER JOIN dim4 dim4 ON  dim2.id_2 = dim4.id_2 "
        + "WHERE ((dim1 . date) = '2014-11-25 00:00:00') "
        + "GROUP BY (dim1 . date),  (dim2 . name), (dim3 . name) , (dim4 . name) ";
    String actual = qtest.rewrite(query, conf, hconf);
    String expected = "select ( dim1___dim1 . date ) as `date` , sum(alias1) as `msr1` , ( dim2___dim2 . name ) "
        + "as `dim2_name` , "
        + "( dim3___dim3 . name ) as `dim3_name` , ( dim4___dim4 . name ) as `dim4_name`  "
        + "from  (select fact___f.dim1_id, fact___f.dim2_id, fact___f.dim3_id,sum(( fact___f . msr1 )) "
        + "as alias1 from fact fact___f where fact___f.dim1_id in  (  select dim1 .id from dim1 where "
        + "(( dim1. date ) =  '2014-11-25 00:00:00' ) )  "
        + "group by fact___f.dim1_id, fact___f.dim2_id, fact___f.dim3_id) "
        + "fact___f  inner join (select id, date from dim1) "
        + "dim1___dim1 on (( fact___f . dim1_id ) = ( dim1___dim1 . id ))  "
        + "inner join (select id, id_2, name from dim2) dim2___dim2 "
        + "on (( fact___f . dim2_id ) = ( dim2___dim2 . id ))  "
        + "inner join (select id, name from dim3) dim3___dim3 on (( fact___f . dim3_id ) = ( dim3___dim3 . id ))  "
        + "inner join (select id_2, name from dim4) dim4___dim4 on (( dim2___dim2 . id_2 ) = ( dim4___dim4 . id_2 ))  "
        + "where (( dim1___dim1 . date ) =  '2014-11-25 00:00:00' ) "
        + "group by ( dim1___dim1 . date ), ( dim2___dim2 . name ), ( dim3___dim3 . name ), ( dim4___dim4 . name )";

    compareQueries(actual, expected);
  }