@FixFor( "MODE-1809" )
@Test
public void shouldBeAbleToCreateAndExecuteJcrSql2UnionOfQueriesWithJoins() throws RepositoryException {

    String sql1 = "SELECT car.* from [car:Car] as car JOIN [nt:unstructured] as category ON ISDESCENDANTNODE(car,category) WHERE NAME(category) LIKE 'Utility'";
    String sql2 = "SELECT car.* from [car:Car] as car JOIN [nt:unstructured] as category ON ISDESCENDANTNODE(car,category) WHERE NAME(category) LIKE 'Sports'";
    String sql = sql1 + " UNION " + sql2;
    String[] columnNames = carColumnNames("car");
    // print = true;
    Query query = session.getWorkspace().getQueryManager().createQuery(sql1, Query.JCR_SQL2);
    QueryResult result = query.execute();
    validateQuery().rowCount(5).hasColumns(columnNames).validate(query, result);
    query = session.getWorkspace().getQueryManager().createQuery(sql2, Query.JCR_SQL2);
    result = query.execute();
    validateQuery().rowCount(2).hasColumns(columnNames).validate(query, result);
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    result = query.execute();
    validateQuery().rowCount(7).hasColumns(columnNames).validate(query, result);
}