orderList.getParserPosition()); select.setOrderBy(expandedOrderList);
private List<Map.Entry<String, RelDataType>> validateMeasure(SqlMatchRecognize mr, MatchRecognizeScope scope, boolean allRows) { final List<String> aliases = new ArrayList<>(); final List<SqlNode> sqlNodes = new ArrayList<>(); final SqlNodeList measures = mr.getMeasureList(); final List<Map.Entry<String, RelDataType>> fields = new ArrayList<>(); for (SqlNode measure : measures) { assert measure instanceof SqlCall; final String alias = deriveAlias(measure, aliases.size()); aliases.add(alias); SqlNode expand = expand(measure, scope); expand = navigationInMeasure(expand, allRows); setOriginal(expand, measure); inferUnknownTypes(unknownType, scope, expand); final RelDataType type = deriveType(scope, expand); setValidatedNodeType(measure, type); fields.add(Pair.of(alias, type)); sqlNodes.add( SqlStdOperatorTable.AS.createCall(SqlParserPos.ZERO, expand, new SqlIdentifier(alias, SqlParserPos.ZERO))); } SqlNodeList list = new SqlNodeList(sqlNodes, measures.getParserPosition()); inferUnknownTypes(unknownType, scope, list); for (SqlNode node : list) { validateExpr(node, scope); } mr.setOperand(SqlMatchRecognize.OPERAND_MEASURES, list); return fields; }
new SqlNodeList( expandedSelectItems, selectItems.getParserPosition()); if (shouldExpandIdentifiers()) { select.setSelectList(newSelectList);
e = new SqlWith(withList.getParserPosition(), withList, e);
expandedList.add(expandedItem); groupList = new SqlNodeList(expandedList, groupList.getParserPosition()); select.setGroupBy(groupList); for (SqlNode groupItem : expandedList) {
new SqlNodeList(sqlNodes, mr.getPatternDefList().getParserPosition()); inferUnknownTypes(unknownType, scope, list); for (SqlNode node : list) {
e = new SqlWith(withList.getParserPosition(), withList, e);
e = new SqlWith(withList.getParserPosition(), withList, e);
private SqlTreeNode convertOrder(SqlSelect select, SqlTreeNode input) { SqlNodeList orderBy = select.getOrderList(); if (orderBy == null || orderBy.getList().isEmpty()) { return input; } return SqlTreeNodes.topn(orderBy.getParserPosition(), input, ""); }
/** * Creates a call to this operand with a list of operands contained in a * {@link SqlNodeList}. * * <p>The position of the resulting call inferred from the SqlNodeList. * * @param nodeList List of arguments * @return call to this operator */ public final SqlCall createCall( SqlNodeList nodeList) { return createCall( null, nodeList.getParserPosition(), nodeList.toArray()); }
/** * Creates a call to this operand with a list of operands contained in a * {@link SqlNodeList}. * * <p>The position of the resulting call inferred from the SqlNodeList. * * @param nodeList List of arguments * @return call to this operator */ public final SqlCall createCall( SqlNodeList nodeList) { return createCall( null, nodeList.getParserPosition(), nodeList.toArray()); }
public SqlNode visit(SqlNodeList nodeList) { boolean update = false; List<SqlNode> exprs = nodeList.getList(); int exprCount = exprs.size(); List<SqlNode> newList = new ArrayList<>(exprCount); for (SqlNode operand : exprs) { SqlNode clonedOperand; if (operand == null) { clonedOperand = null; } else { clonedOperand = operand.accept(this); if (clonedOperand != operand) { update = true; } } newList.add(clonedOperand); } if (update) { return new SqlNodeList(newList, nodeList.getParserPosition()); } else { return nodeList; } }
public SqlNode visit(SqlNodeList nodeList) { boolean update = false; List<SqlNode> exprs = nodeList.getList(); int exprCount = exprs.size(); List<SqlNode> newList = new ArrayList<>(exprCount); for (SqlNode operand : exprs) { SqlNode clonedOperand; if (operand == null) { clonedOperand = null; } else { clonedOperand = operand.accept(this); if (clonedOperand != operand) { update = true; } } newList.add(clonedOperand); } if (update) { return new SqlNodeList(newList, nodeList.getParserPosition()); } else { return nodeList; } }
public SqlNode visit(SqlNodeList list) { SqlNodeList copy = new SqlNodeList(list.getParserPosition()); for (SqlNode node : list) { copy.add(node.accept(this)); } return copy; }
private SqlNode extend(SqlNode table, SqlNodeList extendList) { return SqlStdOperatorTable.EXTEND.createCall( table.getParserPosition().plus(extendList.getParserPosition()), table, extendList); }
public SqlNode visit(SqlNodeList list) { SqlNodeList copy = new SqlNodeList(list.getParserPosition()); for (SqlNode node : list) { copy.add(node.accept(this)); } return copy; }
private SqlNode extend(SqlNode table, SqlNodeList extendList) { return SqlStdOperatorTable.EXTEND.createCall( table.getParserPosition().plus(extendList.getParserPosition()), table, extendList); }
private SqlTreeNode convertSelect(SqlSelect query) { SqlTreeNode input = convertFrom(query.getFrom()); SqlTreeNode filter = convertWhere(input, query.getWhere()); if (filter != null) { input = filter; } if (validator.isAggregate(query)) { SqlNodeList groupList = query.getGroup(); input = SqlTreeNodes.group(groupList.getParserPosition(), input, groupList); } else { SqlNodeList selectList = query.getSelectList(); input = SqlTreeNodes.select(query.getParserPosition(), input, selectList); } return convertOrder(query, input); }
/** * 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)); } }