@FixFor( "MODE-1738" )
@Test
public void shouldSupportJoinWithOrderByOnActualColumn() throws RepositoryException {

    String sql = "SELECT category.[jcr:path], cars.[car:maker], cars.[car:lengthInInches] FROM [nt:unstructured] AS category JOIN [car:Car] AS cars ON ISDESCENDANTNODE(cars,category) WHERE ISCHILDNODE(category,'/Cars') ORDER BY cars.[car:maker]";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    QueryResult result = query.execute();
    String[] expectedColumns = {"category.jcr:path", "cars.car:maker", "cars.car:lengthInInches"};
    validateQuery().rowCount(13).hasColumns(expectedColumns).validate(query, result);
}