Skip to content

Commit

Permalink
[CALCITE-4215] Use default trait value if traitSupplier returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Oct 1, 2020
1 parent ec5b75a commit 97e4f0c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ public <T extends RelMultipleTrait> RelTraitSet replaceIfs(RelTraitDef<T> def,
return this; // trait is not enabled; ignore it
}
final List<T> traitList = traitSupplier.get();
if (traitList == null) {
return replace(index, def.getDefault());
}
return replace(index, RelCompositeTrait.of(def, traitList));
}

Expand All @@ -250,7 +253,10 @@ public <T extends RelTrait> RelTraitSet replaceIf(RelTraitDef<T> def,
if (index < 0) {
return this; // trait is not enabled; ignore it
}
final T traitList = traitSupplier.get();
T traitList = traitSupplier.get();
if (traitList == null) {
traitList = def.getDefault();
}
return replace(index, traitList);
}

Expand Down

0 comments on commit 97e4f0c

Please sign in to comment.