Skip to content

Commit

Permalink
[CALCITE-4215] Avoid NPE when monotonicity is null
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Oct 1, 2020
1 parent 0922441 commit 7df9bba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public RelDataType deriveType(
if (getName().equals("/")) {
final SqlMonotonicity mono0 = call.getOperandMonotonicity(0);
final SqlMonotonicity mono1 = call.getOperandMonotonicity(1);
if (mono0 == null || mono1 == null) {
return null;
}
if (mono1 == SqlMonotonicity.CONSTANT) {
if (call.isOperandLiteral(1, false)) {
switch (call.getOperandLiteralValue(1, BigDecimal.class).signum()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public void unparse(
// SUBSTRING(x FROM 0 FOR constant) has same monotonicity as x
if (call.getOperandCount() == 3) {
final SqlMonotonicity mono0 = call.getOperandMonotonicity(0);
if ((mono0 != SqlMonotonicity.NOT_MONOTONIC)
if (mono0 != null
&& mono0 != SqlMonotonicity.NOT_MONOTONIC
&& call.getOperandMonotonicity(1) == SqlMonotonicity.CONSTANT
&& call.getOperandLiteralValue(1, BigDecimal.class)
.equals(BigDecimal.ZERO)
Expand Down

0 comments on commit 7df9bba

Please sign in to comment.