Hi, I'm attempting to update some code that previously used `withExpand(true)` to use `withExpand(false)`. This has resulted in some plans that previously used left joins to start using `SCALAR_QUERY`.
The code also uses a HepPlanner <https://calcite.apache.org/javadocAggregate/org/apache/calcite/plan/hep/HepPlanner.html> with the FilterReduceExpressionsRule <https://calcite.apache.org/javadocAggregate/org/apache/calcite/rel/rules/ReduceExpressionsRule.FilterReduceExpressionsRule.html#%3Cinit%3E(java.lang.Class,boolean,org.apache.calcite.tools.RelBuilderFactory)>. We use the default configuration and add it to the HepPlanner and then call "findBestExp". When the planner runs, I get a ClassCastException here: https://github.com/apache/calcite/blob/50d124615e0b07f7fbe6107b7c440d9737a00836/core/src/main/java/org/apache/calcite/rex/RexProgramBuilder.java#L303 <https://github.com/apache/calcite/blob/50d124615e0b07f7fbe6107b7c440d9737a00836/core/src/main/java/org/apache/calcite/rex/RexExecutorImpl.java#L76-L77> It seems when the RegisterInputShuttle does its thing, it returns a RexSubQuery instead of a RexLocalRef. Is this a bug or am I doing something wrong with this planner rule? I see this section of code for handling a RexCall and I assume that registerInternal returns a RexLocalRef, but visitSubQuery has its own implementation in the RexShuttle which calls visitList on the subquery. Is this a bug or is there another way I should be doing this? Thanks. --Jonathan Sternberg