aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/sql_match_recognize.h
blob: 6766acc953754ee45516190fe53e0b6a3a301760 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include "sql_translation.h"
#include "match_recognize.h"

namespace NSQLTranslationV1 {

using namespace NSQLv1Generated;

class TSqlMatchRecognizeClause: public TSqlTranslation {
public:
    TSqlMatchRecognizeClause(TContext& ctx, NSQLTranslation::ESqlMode mode)
        : TSqlTranslation(ctx, mode)
    {}
    TMatchRecognizeBuilderPtr CreateBuilder(const TRule_row_pattern_recognition_clause& node);
private:
    TVector<TNamedFunction> ParsePartitionBy(const TRule_window_partition_clause& partitionClause);
    TNamedFunction ParseOneMeasure(const TRule_row_pattern_measure_definition& node);
    TVector<TNamedFunction> ParseMeasures(const TRule_row_pattern_measure_list& node);
    std::pair<TPosition, ERowsPerMatch> ParseRowsPerMatch(const TRule_row_pattern_rows_per_match& rowsPerMatchClause);
    std::pair<TPosition, NYql::NMatchRecognize::TAfterMatchSkipTo> ParseAfterMatchSkipTo(const TRule_row_pattern_skip_to& skipToClause);
    NYql::NMatchRecognize::TRowPatternTerm ParsePatternTerm(const TRule_row_pattern_term& node);
    NYql::NMatchRecognize::TRowPattern ParsePattern(const TRule_row_pattern& node);
    TNamedFunction ParseOneDefinition(const TRule_row_pattern_definition& node);
    TVector<TNamedFunction> ParseDefinitions(const TRule_row_pattern_definition_list& node);
private:
    size_t PatternNestingLevel = 0;
};

} // namespace NSQLTranslationV1