@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { // Monotonic iff its first argument is, but not strict. return call.getOperandMonotonicity(0).unstrict(); }
@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("-")) { return call.getOperandMonotonicity(0).reverse(); } return super.getMonotonicity(call); }
/** * Returns whether any of the given expressions are sorted. * * <p>If so, it can be the default ORDER BY clause for a WINDOW specification. * (This is an extension to the SQL standard for streaming.) */ static boolean containsMonotonic(SelectScope scope, SqlNodeList nodes) { for (SqlNode node : nodes) { if (!scope.getMonotonicity(node).mayRepeat()) { return true; } } return false; }
private List<RelCollation> deduceMonotonicity(SqlValidatorTable table) { final RelDataType rowType = table.getRowType(); final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : rowType.getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of(new RelFieldCollation(i, direction))); } } return collationList; }
@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("-")) { return call.getOperandMonotonicity(0).reverse(); } return super.getMonotonicity(call); }
/** * Returns whether any of the given expressions are sorted. * * <p>If so, it can be the default ORDER BY clause for a WINDOW specification. * (This is an extension to the SQL standard for streaming.) */ static boolean containsMonotonic(SelectScope scope, SqlNodeList nodes) { for (SqlNode node : nodes) { if (!scope.getMonotonicity(node).mayRepeat()) { return true; } } return false; }
private static List<RelCollation> deduceMonotonicity( Prepare.PreparingTable table) { final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : table.getRowType().getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of( new RelFieldCollation(i, direction))); } } return collationList; }
@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { // Monotonic iff its first argument is, but not strict. return call.getOperandMonotonicity(0).unstrict(); }
case -1: return mono0.reverse(); if (getName().equals("-")) { return mono1.reverse(); case -1: return mono1.reverse(); if (mono0 == mono1) { return mono0; } else if (mono0.unstrict() == mono1.unstrict()) { return mono0.unstrict(); } else { return SqlMonotonicity.NOT_MONOTONIC; if (mono0 == mono1.reverse()) { return mono0; } else if (mono0.unstrict() == mono1.reverse().unstrict()) { return mono0.unstrict(); } else { 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; }
/** * Returns whether there are any input columns that are sorted. * * <p>If so, it can be the default ORDER BY clause for a WINDOW specification. * (This is an extension to the SQL standard for streaming.) */ public static boolean containsMonotonic(SqlValidatorScope scope) { for (SqlValidatorNamespace ns : children(scope)) { ns = ns.resolve(); for (String field : ns.getRowType().getFieldNames()) { if (!ns.getMonotonicity(field).mayRepeat()) { return true; } } } return false; }
private static List<RelCollation> deduceMonotonicity( Prepare.PreparingTable table) { final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : table.getRowType().getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of( new RelFieldCollation(i, direction))); } } return collationList; }
case -1: return mono0.reverse(); if (getName().equals("-")) { return mono1.reverse(); case -1: return mono1.reverse(); if (mono0 == mono1) { return mono0; } else if (mono0.unstrict() == mono1.unstrict()) { return mono0.unstrict(); } else { return SqlMonotonicity.NOT_MONOTONIC; if (mono0 == mono1.reverse()) { return mono0; } else if (mono0.unstrict() == mono1.reverse().unstrict()) { return mono0.unstrict(); } else { 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; }
/** * Returns whether there are any input columns that are sorted. * * <p>If so, it can be the default ORDER BY clause for a WINDOW specification. * (This is an extension to the SQL standard for streaming.) */ public static boolean containsMonotonic(SqlValidatorScope scope) { for (SqlValidatorNamespace ns : children(scope)) { ns = ns.resolve(); for (String field : ns.getRowType().getFieldNames()) { if (!ns.getMonotonicity(field).mayRepeat()) { return true; } } } return false; }
private List<RelCollation> deduceMonotonicity(SqlValidatorTable table) { final RelDataType rowType = table.getRowType(); final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : rowType.getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of(new RelFieldCollation(i, direction))); } } return collationList; }