final SqlLiteral rowsPerMatch = matchRecognize.getRowsPerMatch(); final boolean allRows = rowsPerMatch != null && rowsPerMatch.getValue() SqlNodeList partitionBy = matchRecognize.getPartitionList(); if (partitionBy != null) { for (SqlNode node : partitionBy) { SqlNodeList orderBy = matchRecognize.getOrderList(); if (orderBy != null) { for (SqlNode node : orderBy) { getNamespace(matchRecognize.getTableRef()); final RelDataType inputDataType = sqlNs.getRowType(); for (RelDataTypeField fs : inputDataType.getFieldList()) { SqlNode pattern = matchRecognize.getPattern(); PatternVarVisitor visitor = new PatternVarVisitor(scope); pattern.accept(visitor); SqlLiteral interval = matchRecognize.getInterval(); if (interval != null) { interval.validate(this, scope); SqlNodeList subsets = matchRecognize.getSubsetList(); if (subsets != null && subsets.size() > 0) { for (SqlNode node : subsets) { final SqlNode skipTo = matchRecognize.getAfter();
private void validateDefinitions(SqlMatchRecognize mr, MatchRecognizeScope scope) { final Set<String> aliases = catalogReader.nameMatcher().createSet(); for (SqlNode item : mr.getPatternDefList().getList()) { final String alias = alias(item); if (!aliases.add(alias)) { for (SqlNode item : mr.getPatternDefList().getList()) { final String alias = alias(item); SqlNode expand = expand(item, scope); new SqlNodeList(sqlNodes, mr.getPatternDefList().getParserPosition()); inferUnknownTypes(unknownType, scope, list); for (SqlNode node : list) { validateExpr(node, scope); mr.setOperand(SqlMatchRecognize.OPERAND_PATTERN_DEFINES, list);
private void registerMatchRecognize( SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlMatchRecognize call, SqlNode enclosingNode, String alias, boolean forceNullable) { final MatchRecognizeNamespace matchRecognizeNamespace = createMatchRecognizeNameSpace(call, enclosingNode); registerNamespace(usingScope, alias, matchRecognizeNamespace, forceNullable); final MatchRecognizeScope matchRecognizeScope = new MatchRecognizeScope(parentScope, call); scopes.put(call, matchRecognizeScope); // parse input query SqlNode expr = call.getTableRef(); SqlNode newExpr = registerFrom(usingScope, matchRecognizeScope, true, expr, expr, null, null, forceNullable, false); if (expr != newExpr) { call.setOperand(0, newExpr); } }
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; }
SqlNode expr = matchRecognize.getTableRef(); convertFrom(matchBb, expr); final RelNode input = matchBb.root; final SqlNodeList partitionList = matchRecognize.getPartitionList(); final List<RexNode> partitionKeys = new ArrayList<>(); for (SqlNode partition : partitionList) { final SqlNodeList orderList = matchRecognize.getOrderList(); final List<RelFieldCollation> orderKeys = new ArrayList<>(); for (SqlNode order : orderList) { SqlNode pattern = matchRecognize.getPattern(); final SqlBasicVisitor<RexNode> patternVarVisitor = new SqlBasicVisitor<RexNode>() { SqlLiteral interval = matchRecognize.getInterval(); RexNode intervalNode = null; if (interval != null) { final SqlNodeList subsets = matchRecognize.getSubsetList(); final Map<String, TreeSet<String>> subsetMap = new HashMap<>(); for (SqlNode node : subsets) { SqlNode afterMatch = matchRecognize.getAfter(); if (afterMatch == null) { afterMatch = for (SqlNode measure : matchRecognize.getMeasureList()) {
@Override public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands) { assert functionQualifier == null; assert operands.length == 12; return new SqlMatchRecognize(pos, operands[0], operands[1], (SqlLiteral) operands[2], (SqlLiteral) operands[3], (SqlNodeList) operands[4], (SqlNodeList) operands[5], operands[6], (SqlNodeList) operands[7], (SqlLiteral) operands[8], (SqlNodeList) operands[9], (SqlNodeList) operands[10], (SqlLiteral) operands[11]); }
final RelDataType rowType = ns.getRowType(); SqlNode expr = matchRecognize.getTableRef(); convertFrom(mrBlackBoard, expr); final RelNode input = mrBlackBoard.root; SqlNode pattern = matchRecognize.getPattern(); final SqlBasicVisitor<RexNode> patternVarVisitor = new SqlBasicVisitor<RexNode>() { for (SqlNode def : matchRecognize.getPatternDefList()) { List<SqlNode> operands = ((SqlCall) def).getOperandList(); String alias = ((SqlIdentifier) operands.get(1)).getSimple(); final RelNode rel = factory.createMatchRecognize(input, patternNode, matchRecognize.getStrictStart().booleanValue(), matchRecognize.getStrictEnd().booleanValue(), definitionNodes.build(), rowType);
private SqlTreeNode convertMatchRecognize(SqlCall call) { SqlMatchRecognize matchRecognize = (SqlMatchRecognize) call; SqlNode tableRef = matchRecognize.getTableRef(); SqlTreeNode input = convertFrom(tableRef); SqlNode pattern = matchRecognize.getPattern(); return SqlTreeNodes.cep(call.getParserPosition(), input, pattern); }
for (SqlNode node : pattern.getPatternDefList()) { final SqlCall call2 = (SqlCall) node;
SqlNode expr = matchRecognize.getTableRef(); convertFrom(matchBb, expr); final RelNode input = matchBb.root; final SqlNodeList partitionList = matchRecognize.getPartitionList(); final List<RexNode> partitionKeys = new ArrayList<>(); for (SqlNode partition : partitionList) { final SqlNodeList orderList = matchRecognize.getOrderList(); final List<RelFieldCollation> orderKeys = new ArrayList<>(); for (SqlNode order : orderList) { SqlNode pattern = matchRecognize.getPattern(); final SqlBasicVisitor<RexNode> patternVarVisitor = new SqlBasicVisitor<RexNode>() { SqlLiteral interval = matchRecognize.getInterval(); RexNode intervalNode = null; if (interval != null) { final SqlNodeList subsets = matchRecognize.getSubsetList(); final Map<String, TreeSet<String>> subsetMap = new HashMap<>(); for (SqlNode node : subsets) { SqlNode afterMatch = matchRecognize.getAfter(); if (afterMatch == null) { afterMatch = for (SqlNode measure : matchRecognize.getMeasureList()) {
@Override public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands) { assert functionQualifier == null; assert operands.length == 12; return new SqlMatchRecognize(pos, operands[0], operands[1], (SqlLiteral) operands[2], (SqlLiteral) operands[3], (SqlNodeList) operands[4], (SqlNodeList) operands[5], operands[6], (SqlNodeList) operands[7], (SqlLiteral) operands[8], (SqlNodeList) operands[9], (SqlNodeList) operands[10], (SqlLiteral) operands[11]); }
private void registerMatchRecognize( SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlMatchRecognize call, SqlNode enclosingNode, String alias, boolean forceNullable) { final MatchRecognizeNamespace matchRecognizeNamespace = createMatchRecognizeNameSpace(call, enclosingNode); registerNamespace(usingScope, alias, matchRecognizeNamespace, forceNullable); final MatchRecognizeScope matchRecognizeScope = new MatchRecognizeScope(parentScope, call); scopes.put(call, matchRecognizeScope); // parse input query SqlNode expr = call.getTableRef(); SqlNode newExpr = registerFrom(usingScope, matchRecognizeScope, true, expr, expr, null, null, forceNullable, false); if (expr != newExpr) { call.setOperand(0, newExpr); } }
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; }
for (SqlNode node : pattern.getPatternDefList()) { final SqlCall call2 = (SqlCall) node;
SqlNode expr = matchRecognize.getTableRef(); convertFrom(matchBb, expr); final RelNode input = matchBb.root; final SqlNodeList partitionList = matchRecognize.getPartitionList(); final List<RexNode> partitionKeys = new ArrayList<>(); for (SqlNode partition : partitionList) { final SqlNodeList orderList = matchRecognize.getOrderList(); final List<RelFieldCollation> orderKeys = new ArrayList<>(); for (SqlNode order : orderList) { SqlNode pattern = matchRecognize.getPattern(); final SqlBasicVisitor<RexNode> patternVarVisitor = new SqlBasicVisitor<RexNode>() { final SqlNodeList subsets = matchRecognize.getSubsetList(); final Map<String, TreeSet<String>> subsetMap = Maps.newHashMap(); for (SqlNode node : subsets) { SqlNode afterMatch = matchRecognize.getAfter(); if (afterMatch == null) { afterMatch = for (SqlNode measure : matchRecognize.getMeasureList()) { List<SqlNode> operands = ((SqlCall) measure).getOperandList(); String alias = ((SqlIdentifier) operands.get(1)).getSimple(); for (SqlNode def : matchRecognize.getPatternDefList()) {
final SqlLiteral rowsPerMatch = matchRecognize.getRowsPerMatch(); final boolean allRows = rowsPerMatch != null && rowsPerMatch.getValue() SqlNodeList partitionBy = matchRecognize.getPartitionList(); if (partitionBy != null) { for (SqlNode node : partitionBy) { SqlNodeList orderBy = matchRecognize.getOrderList(); if (orderBy != null) { for (SqlNode node : orderBy) { getNamespace(matchRecognize.getTableRef()); final RelDataType inputDataType = sqlNs.getRowType(); for (RelDataTypeField fs : inputDataType.getFieldList()) { SqlNode pattern = matchRecognize.getPattern(); PatternVarVisitor visitor = new PatternVarVisitor(scope); pattern.accept(visitor); SqlLiteral interval = matchRecognize.getInterval(); if (interval != null) { interval.validate(this, scope); SqlNodeList subsets = matchRecognize.getSubsetList(); if (subsets != null && subsets.size() > 0) { for (SqlNode node : subsets) { final SqlNode skipTo = matchRecognize.getAfter();
patternDefList = PatternDefinitionCommaList(span()); jj_consume_token(RPAREN); {if (true) return new SqlMatchRecognize(s.end(this), tableRef, pattern, isStrictStarts, isStrictEnds, patternDefList, measureList, after, subsetList, rowsPerMatch, partitionList, orderList, interval);}
private void registerMatchRecognize( SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlMatchRecognize call, SqlNode enclosingNode, String alias, boolean forceNullable) { final MatchRecognizeNamespace matchRecognizeNamespace = createMatchRecognizeNameSpace(call, enclosingNode); registerNamespace(usingScope, alias, matchRecognizeNamespace, forceNullable); final MatchRecognizeScope matchRecognizeScope = new MatchRecognizeScope(parentScope, call); scopes.put(call, matchRecognizeScope); // parse input query SqlNode expr = call.getTableRef(); SqlNode newExpr = registerFrom(usingScope, matchRecognizeScope, true, expr, expr, null, null, forceNullable, false); if (expr != newExpr) { call.setOperand(0, newExpr); } }
private void validateDefinitions(SqlMatchRecognize mr, MatchRecognizeScope scope) { final Set<String> aliases = catalogReader.nameMatcher().createSet(); for (SqlNode item : mr.getPatternDefList().getList()) { final String alias = alias(item); if (!aliases.add(alias)) { for (SqlNode item : mr.getPatternDefList().getList()) { final String alias = alias(item); SqlNode expand = expand(item, scope); new SqlNodeList(sqlNodes, mr.getPatternDefList().getParserPosition()); inferUnknownTypes(unknownType, scope, list); for (SqlNode node : list) { validateExpr(node, scope); mr.setOperand(SqlMatchRecognize.OPERAND_PATTERN_DEFINES, list);
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; }