case PRECEDING: if (amt == null) { rwb = RexWindowBound.create(SqlWindow.createUnboundedPreceding(pos), null); } else { sc = (SqlCall) SqlWindow.createPreceding(amt, pos);
case PRECEDING: if (amt == null) { rwb = RexWindowBound.create(SqlWindow.createUnboundedPreceding(pos), null); } else { sc = (SqlCall) SqlWindow.createPreceding(amt, pos);
if (jj_2_184(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_185(2)) { jj_consume_token(FOLLOWING);
if (jj_2_184(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_185(2)) { jj_consume_token(FOLLOWING);
if (jj_2_186(2)) { jj_consume_token(PRECEDING); {if ("" != null) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_187(2)) { jj_consume_token(FOLLOWING);
public RexNode makeOver( SqlAggFunction operator, List<RexNode> expressions, List<RexNode> partitionKeys ) { final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class); // TODO // This is a temporal fix to make HAWQ work with OVER + UNLIMITED BOUNDS // HAWQ requires ORDER BY if andy BOUNDS are set even unlimited upper and lower BOUNDS (which is equal to // the entire partition - e.g. not setting BOUNDs at all -- // Note that the unnecessary ORDER BY have negative performance impact and has to be remove once either HAWQ // start supporting unbounded bounds without order by or Calcite can generate shorthand OVER PARTITION BY // syntax. List<RexFieldCollation> orderKeys = expressions.stream().map( rexNode -> new RexFieldCollation(rexNode, flags)).collect(Collectors.toList()); return makeOver( operator, expressions, partitionKeys, ImmutableList.copyOf(orderKeys), RexWindowBound.create(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO), null), RexWindowBound.create(SqlWindow.createUnboundedFollowing(SqlParserPos.ZERO), null), true, true, false ); }
/** * Creates a window <code>(RANGE <i>columnName</i> UNBOUNDED * PRECEDING)</code>. * * @param columnName Order column */ public SqlWindow createUnboundedPrecedingWindow(final String columnName) { return SqlWindow.create( null, null, new SqlNodeList(SqlParserPos.ZERO), new SqlNodeList( ImmutableList.of( new SqlIdentifier(columnName, SqlParserPos.ZERO)), SqlParserPos.ZERO), SqlLiteral.createBoolean(false, SqlParserPos.ZERO), SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO), SqlWindow.createCurrentRow(SqlParserPos.ZERO), SqlLiteral.createBoolean(false, SqlParserPos.ZERO), SqlParserPos.ZERO); }
/** * Creates a window <code>(RANGE <i>columnName</i> UNBOUNDED * PRECEDING)</code>. * * @param columnName Order column */ public SqlWindow createUnboundedPrecedingWindow(final String columnName) { return SqlWindow.create( null, null, new SqlNodeList(SqlParserPos.ZERO), new SqlNodeList( ImmutableList.of( new SqlIdentifier(columnName, SqlParserPos.ZERO)), SqlParserPos.ZERO), SqlLiteral.createBoolean(false, SqlParserPos.ZERO), SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO), SqlWindow.createCurrentRow(SqlParserPos.ZERO), SqlLiteral.createBoolean(false, SqlParserPos.ZERO), SqlParserPos.ZERO); }
private SqlNode createSqlWindowBound(RexWindowBound rexWindowBound) { if (rexWindowBound.isCurrentRow()) { return SqlWindow.createCurrentRow(POS); } if (rexWindowBound.isPreceding()) { if (rexWindowBound.isUnbounded()) { return SqlWindow.createUnboundedPreceding(POS); } else { SqlNode literal = toSql(null, rexWindowBound.getOffset()); return SqlWindow.createPreceding(literal, POS); } } if (rexWindowBound.isFollowing()) { if (rexWindowBound.isUnbounded()) { return SqlWindow.createUnboundedFollowing(POS); } else { SqlNode literal = toSql(null, rexWindowBound.getOffset()); return SqlWindow.createFollowing(literal, POS); } } throw new AssertionError("Unsupported Window bound: " + rexWindowBound); }
private SqlNode createSqlWindowBound(RexWindowBound rexWindowBound) { if (rexWindowBound.isCurrentRow()) { return SqlWindow.createCurrentRow(POS); } if (rexWindowBound.isPreceding()) { if (rexWindowBound.isUnbounded()) { return SqlWindow.createUnboundedPreceding(POS); } else { SqlNode literal = toSql(null, rexWindowBound.getOffset()); return SqlWindow.createPreceding(literal, POS); } } if (rexWindowBound.isFollowing()) { if (rexWindowBound.isUnbounded()) { return SqlWindow.createUnboundedFollowing(POS); } else { SqlNode literal = toSql(null, rexWindowBound.getOffset()); return SqlWindow.createFollowing(literal, POS); } } throw new AssertionError("Unsupported Window bound: " + rexWindowBound); }
/** * Fill in missing bounds. Default bounds are "BETWEEN UNBOUNDED PRECEDING * AND CURRENT ROW" when ORDER BY present and "BETWEEN UNBOUNDED PRECEDING * AND UNBOUNDED FOLLOWING" when no ORDER BY present. */ public void populateBounds() { if (lowerBound == null && upperBound == null) { setLowerBound( SqlWindow.createUnboundedPreceding(getParserPosition())); } if (lowerBound == null) { setLowerBound( SqlWindow.createCurrentRow(getParserPosition())); } if (upperBound == null) { SqlParserPos pos = orderList.getParserPosition(); setUpperBound( orderList.size() == 0 ? SqlWindow.createUnboundedFollowing(pos) : SqlWindow.createCurrentRow(pos)); } }
/** * Fill in missing bounds. Default bounds are "BETWEEN UNBOUNDED PRECEDING * AND CURRENT ROW" when ORDER BY present and "BETWEEN UNBOUNDED PRECEDING * AND UNBOUNDED FOLLOWING" when no ORDER BY present. */ public void populateBounds() { if (lowerBound == null && upperBound == null) { setLowerBound( SqlWindow.createUnboundedPreceding(getParserPosition())); } if (lowerBound == null) { setLowerBound( SqlWindow.createCurrentRow(getParserPosition())); } if (upperBound == null) { SqlParserPos pos = orderList.getParserPosition(); setUpperBound( orderList.size() == 0 ? SqlWindow.createUnboundedFollowing(pos) : SqlWindow.createCurrentRow(pos)); } }
case PRECEDING: if (amt == null) { rwb = RexWindowBound.create(SqlWindow.createUnboundedPreceding(pos), null); } else { sc = (SqlCall) SqlWindow.createPreceding(amt, pos);
if (jj_2_314(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_315(2)) { jj_consume_token(FOLLOWING);
if (jj_2_189(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_190(2)) { jj_consume_token(FOLLOWING);
if (jj_2_182(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_183(2)) { jj_consume_token(FOLLOWING);
if (jj_2_177(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_178(2)) { jj_consume_token(FOLLOWING);
if (jj_2_219(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_220(2)) { jj_consume_token(FOLLOWING);
if (jj_2_220(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_221(2)) { jj_consume_token(FOLLOWING);
if (jj_2_180(2)) { jj_consume_token(PRECEDING); {if (true) return SqlWindow.createUnboundedPreceding(s.end(this));} } else if (jj_2_181(2)) { jj_consume_token(FOLLOWING);