bug fix in IndexStatementRewriter and JoinCompiler