yql_match_recognize.h 1.2 KB

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <yql/essentials/core/sql_types/match_recognize.h>
  3. #include "yql/essentials/ast/yql_expr.h"
  4. namespace NYql::NMatchRecognize {
  5. inline TRowPattern ConvertPattern(const TExprNode::TPtr& pattern, TExprContext &ctx, size_t nestingLevel = 0) {
  6. YQL_ENSURE(nestingLevel <= MaxPatternNesting, "To big nesting level in the pattern");
  7. TRowPattern result;
  8. for (const auto& term: pattern->Children()) {
  9. result.push_back(TRowPatternTerm{});
  10. for (const auto& factor: term->Children()) {
  11. YQL_ENSURE(factor->ChildrenSize() == 6, "Expect 6 args");
  12. result.back().push_back(TRowPatternFactor{
  13. factor->Child(0)->IsAtom() ?
  14. TRowPatternPrimary(TString(factor->Child(0)->Content())) :
  15. ConvertPattern(factor->Child(0), ctx, nestingLevel + 1),
  16. FromString<ui64>(factor->Child(1)->Content()),
  17. FromString<ui64>(factor->Child(2)->Content()),
  18. FromString<bool>(factor->Child(3)->Content()),
  19. FromString<bool>(factor->Child(4)->Content()),
  20. FromString<bool>(factor->Child(5)->Content())
  21. });
  22. }
  23. }
  24. return result;
  25. }
  26. } //namespace NYql::NMatchRecognize