Repository navigation
[CALCITE-7967] Run sub-query removal before RelDecorrelator in the default planning pipeline - #5462
iwanttobepowerful wants to merge 1 commit into
Conversation
e4e1559 to
d74132c
Compare
6c70d9b to
5b3ea80
Compare
| if (this.context.config().forceDecorrelate() | ||
| && !this.context.config().topDownGeneralDecorrelationEnabled()) { | ||
| && !this.context.config().topDownGeneralDecorrelationEnabled() | ||
| && configHolder.get().isExpand()) { |
There was a problem hiding this comment.
added a new isDecorrelateAfterSubQueryRemoval config
|
|
||
| // TopDownGeneralDecorrelator cannot be used until the subquerys are completely removed. | ||
| // Likewise, if the sub-queries were not expanded during sql-to-rel, defer | ||
| // decorrelation to the program: RelDecorrelator must not run before the |
There was a problem hiding this comment.
what is "the program"?
(couldn't tell from a scan of the code around, maybe it's obvious if you read more of the class)
| * <p>The decorrelator must not see a mixture of {@code RexSubQuery} | ||
| * expressions and {@code Correlate} nodes, otherwise it can leave dangling | ||
| * correlation variables. Default is true. */ | ||
| @Value.Default default boolean isDecorrelateAfterSubQueryRemoval() { |
There was a problem hiding this comment.
I don't understand why this config option is in SqlToRelConverter yet the converter never looks at the option.
There was a problem hiding this comment.
Thanks for pointing this out. You’re right: this option controls the planning pipeline, not SQL-to-rel conversion, so it does not belong in SqlToRelConverter.Config.
I’ve removed the option and the early decorrelation call in Prepare. The default pipeline now relies on Programs.standard(), which already runs sub-query removal before decorrelation. This makes the ordering unconditional rather than configurable. forceDecorrelate is unchanged and still controls whether decorrelation is attempted.
I also added regression tests covering both decorrelators with expansion enabled and disabled, and verifying that forceDecorrelate=false preserves EnumerableCorrelate. The full core test suite and Checkstyle checks pass.
| * expressions (for example when {@link #isExpand()} is false); the planner | ||
| * program removes the sub-queries first and then decorrelates. | ||
| * | ||
| * <p>The decorrelator must not see a mixture of {@code RexSubQuery} |
There was a problem hiding this comment.
instead of producing an incorrect plan the decorrelator should just throw if it cannot produce its result
…fault planning pipeline
e902d02 to
195ac6d
Compare
|



CALCITE-7967