yql_match_recognize.h 1.1 KB

12345678910111213141516171819202122232425262728
  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) {
  6. TRowPattern result;
  7. for (const auto& term: pattern->Children()) {
  8. result.push_back(TRowPatternTerm{});
  9. for (const auto& factor: term->Children()) {
  10. YQL_ENSURE(factor->ChildrenSize() == 6, "Expect 6 args");
  11. result.back().push_back(TRowPatternFactor{
  12. factor->Child(0)->IsAtom() ?
  13. TRowPatternPrimary(TString(factor->Child(0)->Content())) :
  14. ConvertPattern(factor->Child(0), ctx),
  15. FromString<ui64>(factor->Child(1)->Content()),
  16. FromString<ui64>(factor->Child(2)->Content()),
  17. FromString<bool>(factor->Child(3)->Content()),
  18. FromString<bool>(factor->Child(4)->Content()),
  19. FromString<bool>(factor->Child(5)->Content())
  20. });
  21. }
  22. }
  23. return result;
  24. }
  25. } //namespace NYql::NMatchRecognize