sql_match_recognize.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "match_recognize.h"
  3. #include "node.h"
  4. #include "sql_translation.h"
  5. namespace NSQLTranslationV1 {
  6. class TSqlMatchRecognizeClause final : public TSqlTranslation {
  7. public:
  8. TSqlMatchRecognizeClause(TContext& ctx, NSQLTranslation::ESqlMode mode);
  9. TMatchRecognizeBuilderPtr CreateBuilder(const TRule_row_pattern_recognition_clause& node);
  10. static constexpr size_t MaxPatternNesting = 20;
  11. static constexpr size_t MaxPermutedItems = 6;
  12. private:
  13. std::tuple<TNodePtr, TNodePtr> ParsePartitionBy(TPosition pos, const TRule_window_partition_clause* node);
  14. TMaybe<TVector<TSortSpecificationPtr>> ParseOrderBy(const TRule_order_by_clause* node);
  15. TNamedFunction ParseOneMeasure(const TRule_row_pattern_measure_definition& node);
  16. TVector<TNamedFunction> ParseMeasures(const TRule_row_pattern_measure_list* node);
  17. TNodePtr ParseRowsPerMatch(TPosition pos, const TRule_row_pattern_rows_per_match* node);
  18. TNodePtr ParseAfterMatchSkipTo(TPosition pos, const TRule_row_pattern_skip_to* node);
  19. TNodePtr BuildPatternFactor(TPosition pos, TNodePtr primary, std::tuple<ui64, ui64, bool, bool, bool> quantifier);
  20. TNodePtr ParsePatternFactor(TPosition pos, const TRule_row_pattern_factor& node, size_t nestingLevel, bool output);
  21. TNodePtr BuildPatternTerm(TPosition pos, std::vector<TNodePtr> term);
  22. TNodePtr ParsePatternTerm(TPosition pos, const TRule_row_pattern_term& node, size_t nestingLevel, bool output);
  23. TNodePtr BuildPattern(TPosition pos, std::vector<TNodePtr> pattern);
  24. TNodePtr ParsePattern(TPosition pos, const TRule_row_pattern& node, size_t nestingLevel, bool output);
  25. TMaybe<TNodePtr> ParseSubset(TPosition pos, const TRule_row_pattern_subset_clause* node);
  26. TNamedFunction ParseOneDefinition(const TRule_row_pattern_definition& node);
  27. TVector<TNamedFunction> ParseDefinitions(const TRule_row_pattern_definition_list& node);
  28. private:
  29. THashSet<TString> PatternVarNames;
  30. TNodePtr PatternVars;
  31. };
  32. } // namespace NSQLTranslationV1