@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { if (getName().equals("-")) { return call.getOperandMonotonicity(0).reverse(); } return super.getMonotonicity(call); }
@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { if (getName().equals("-")) { return call.getOperandMonotonicity(0).reverse(); } return super.getMonotonicity(call); }
@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: // mono / -ve constant --> reverse mono, unstrict return mono0.reverse().unstrict(); case 0: // mono / zero --> constant (infinity!) return SqlMonotonicity.CONSTANT; default: // mono / +ve constant * mono1 --> mono, unstrict return mono0.unstrict(); } } } } return super.getMonotonicity(call); }
@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: // mono / -ve constant --> reverse mono, unstrict return mono0.reverse().unstrict(); case 0: // mono / zero --> constant (infinity!) return SqlMonotonicity.CONSTANT; default: // mono / +ve constant * mono1 --> mono, unstrict return mono0.unstrict(); } } } } return super.getMonotonicity(call); }
public SqlMonotonicity getMonotonicity(SqlNode expr) { SqlMonotonicity monotonicity = expr.getMonotonicity(this); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { return monotonicity; } // TODO: compare fully qualified names final SqlNodeList orderList = getOrderList(); if (orderList.size() > 0) { SqlNode order0 = orderList.get(0); monotonicity = SqlMonotonicity.INCREASING; if ((order0 instanceof SqlCall) && (((SqlCall) order0).getOperator() == SqlStdOperatorTable.DESC)) { monotonicity = monotonicity.reverse(); order0 = ((SqlCall) order0).operand(0); } if (expr.equalsDeep(order0, Litmus.IGNORE)) { return monotonicity; } } return SqlMonotonicity.NOT_MONOTONIC; }
public SqlMonotonicity getMonotonicity(SqlNode expr) { SqlMonotonicity monotonicity = expr.getMonotonicity(this); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { return monotonicity; } // TODO: compare fully qualified names final SqlNodeList orderList = getOrderList(); if (orderList.size() > 0) { SqlNode order0 = orderList.get(0); monotonicity = SqlMonotonicity.INCREASING; if ((order0 instanceof SqlCall) && (((SqlCall) order0).getOperator() == SqlStdOperatorTable.DESC)) { monotonicity = monotonicity.reverse(); order0 = ((SqlCall) order0).operand(0); } if (expr.equalsDeep(order0, Litmus.IGNORE)) { return monotonicity; } } return SqlMonotonicity.NOT_MONOTONIC; }