Here's a sample issue:

core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java:161:
error: [dereference.of.nullable] dereference of possibly-null reference
call.getOperandLiteralValue(1, BigDecimal.class)
          switch (call.getOperandLiteralValue(1,
BigDecimal.class).signum()) {
                                             ^
The code in question is

@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) {
  if (getName().equals("/")) {
    final SqlMonotonicity mono0 = call.getOperandMonotonicity(0);
    final SqlMonotonicity mono1 = call.getOperandMonotonicity(1);
    if (mono1 == SqlMonotonicity.CONSTANT) {
      if (call.isOperandLiteral(1, false)) {
        switch (call.getOperandLiteralValue(1, BigDecimal.class).signum()) {
        case -1:


The error message suggests that the test for 1/null is missing, and it
turns out it is a true bug:

@Test void testMonotonic() {
  sql("select stream 1/null from orders")
      .monotonic(SqlMonotonicity.CONSTANT);


java.lang.NullPointerException
at
org.apache.calcite.sql.SqlBinaryOperator.getMonotonicity(SqlBinaryOperator.java:161)
at org.apache.calcite.sql.SqlCall.getMonotonicity(SqlCall.java:193)
at
org.apache.calcite.sql.validate.SelectScope.getMonotonicity(SelectScope.java:159)
at
org.apache.calcite.sql.validate.SelectNamespace.getMonotonicity(SelectNamespace.java:76)
at
org.apache.calcite.sql.test.AbstractSqlTester.checkMonotonic(AbstractSqlTester.java:497)
at
org.apache.calcite.test.SqlValidatorTestCase$Sql.monotonic(SqlValidatorTestCase.java:373)

Vladimir

Reply via email to