Update rule change
60 lines
@Value.Immutable
public interface Config extends RelRule.Config {
public interface Config extends RelRule.Config {
Config DEFAULT = EMPTY.as(Config.class)
Config DEFAULT = ImmutableProjectFilterTransposeRule.of()
.withOperandFor(LogicalProject.class, LogicalFilter.class)
.withOperandFor(LogicalProject.class, LogicalFilter.class)
.withPreserveExprCondition(expr -> false)
.withPreserveExprCondition(expr -> false)
.withWholeProject(false)
.withWholeProject(false)
.withWholeFilter(false);
.withWholeFilter(false);
Config PROJECT = DEFAULT.withWholeProject(true);
Config PROJECT = DEFAULT.withWholeProject(true);
Config PROJECT_FILTER = PROJECT.withWholeFilter(true);
Config PROJECT_FILTER = PROJECT.withWholeFilter(true);
@Override default ProjectFilterTransposeRule toRule() {
@Override default ProjectFilterTransposeRule toRule() {
return new ProjectFilterTransposeRule(this);
return new ProjectFilterTransposeRule(this);
}
}
/** Expressions that should be preserved in the projection. */
/** Expressions that should be preserved in the projection. */
@ImmutableBeans.Property
PushProjector.ExprCondition preserveExprCondition();
PushProjector.ExprCondition preserveExprCondition();
/** Sets {@link #preserveExprCondition()}. */
/** Sets {@link #preserveExprCondition()}. */
Config withPreserveExprCondition(PushProjector.ExprCondition condition);
Config withPreserveExprCondition(PushProjector.ExprCondition condition);
/** Whether to push whole expressions from the project;
/** Whether to push whole expressions from the project;
* if false (the default), only pushes references. */
* if false (the default), only pushes references. */
@ImmutableBeans.Property
@Value.Default default boolean isWholeProject() {
@ImmutableBeans.BooleanDefault(false)
return false;
boolean isWholeProject();
}
/** Sets {@link #isWholeProject()}. */
/** Sets {@link #isWholeProject()}. */
Config withWholeProject(boolean wholeProject);
Config withWholeProject(boolean wholeProject);
/** Whether to push whole expressions from the filter;
/** Whether to push whole expressions from the filter;
* if false (the default), only pushes references. */
* if false (the default), only pushes references. */
@ImmutableBeans.Property
@Value.Default default boolean isWholeFilter() {
@ImmutableBeans.BooleanDefault(false)
return false;
boolean isWholeFilter();
}
/** Sets {@link #isWholeFilter()}. */
/** Sets {@link #isWholeFilter()}. */
Config withWholeFilter(boolean wholeFilter);
Config withWholeFilter(boolean wholeFilter);
/** Defines an operand tree for the given classes. */
/** Defines an operand tree for the given classes. */
default Config withOperandFor(Class<? extends Project> projectClass,
default Config withOperandFor(Class<? extends Project> projectClass,
Class<? extends Filter> filterClass) {
Class<? extends Filter> filterClass) {
return withOperandSupplier(b0 ->
return withOperandSupplier(b0 ->
b0.operand(projectClass).oneInput(b1 ->
b0.operand(projectClass).oneInput(b1 ->
b1.operand(filterClass).anyInputs()))
b1.operand(filterClass).anyInputs()));
.as(Config.class);
}
}
/** Defines an operand tree for the given 3 classes. */
/** Defines an operand tree for the given 3 classes. */
default Config withOperandFor(Class<? extends Project> projectClass,
default Config withOperandFor(Class<? extends Project> projectClass,
Class<? extends Filter> filterClass,
Class<? extends Filter> filterClass,
Class<? extends RelNode> inputClass) {
Class<? extends RelNode> inputClass) {
return withOperandSupplier(b0 ->
return withOperandSupplier(b0 ->
b0.operand(projectClass).oneInput(b1 ->
b0.operand(projectClass).oneInput(b1 ->
b1.operand(filterClass).oneInput(b2 ->
b1.operand(filterClass).oneInput(b2 ->
b2.operand(inputClass).anyInputs())))
b2.operand(inputClass).anyInputs())));
.as(Config.class);
}
}
}
}