yql_opt_hopping.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <yql/essentials/core/expr_nodes/yql_expr_nodes.h>
  3. #include <yql/essentials/ast/yql_expr.h>
  4. #include <util/datetime/base.h>
  5. namespace NYql::NHopping {
  6. struct THoppingTraits {
  7. TString Column;
  8. NYql::NNodes::TCoHoppingTraits Traits;
  9. ui64 Hop;
  10. ui64 Interval;
  11. ui64 Delay;
  12. };
  13. struct TKeysDescription {
  14. TVector<TString> PickleKeys;
  15. TVector<TString> MemberKeys;
  16. TVector<TString> FakeKeys;
  17. TKeysDescription(const TStructExprType& rowType, const NYql::NNodes::TCoAtomList& keys, const TString& hoppingColumn);
  18. TExprNode::TPtr BuildPickleLambda(TExprContext& ctx, TPositionHandle pos) const;
  19. TExprNode::TPtr BuildUnpickleLambda(TExprContext& ctx, TPositionHandle pos, const TStructExprType& rowType);
  20. TVector<NYql::NNodes::TCoAtom> GetKeysList(TExprContext& ctx, TPositionHandle pos) const;
  21. TVector<TString> GetActualGroupKeys() const;
  22. bool NeedPickle() const;
  23. TExprNode::TPtr GetKeySelector(TExprContext& ctx, TPositionHandle pos, const TStructExprType* rowType);
  24. };
  25. TString BuildColumnName(const NYql::NNodes::TExprBase& column);
  26. bool IsLegacyHopping(const TExprNode::TPtr& hoppingSetting);
  27. void EnsureNotDistinct(const NYql::NNodes::TCoAggregate& aggregate);
  28. TMaybe<THoppingTraits> ExtractHopTraits(const NYql::NNodes::TCoAggregate& aggregate, TExprContext& ctx, bool analyticsMode);
  29. TExprNode::TPtr BuildTimeExtractor(const NYql::NNodes::TCoHoppingTraits& hoppingTraits, TExprContext& ctx);
  30. TExprNode::TPtr BuildInitHopLambda(const NYql::NNodes::TCoAggregate& aggregate, TExprContext& ctx);
  31. TExprNode::TPtr BuildUpdateHopLambda(const NYql::NNodes::TCoAggregate& aggregate, TExprContext& ctx);
  32. TExprNode::TPtr BuildMergeHopLambda(const NYql::NNodes::TCoAggregate& aggregate, TExprContext& ctx);
  33. TExprNode::TPtr BuildFinishHopLambda(
  34. const NYql::NNodes::TCoAggregate& aggregate,
  35. const TVector<TString>& actualGroupKeys,
  36. const TString& hoppingColumn,
  37. TExprContext& ctx);
  38. TExprNode::TPtr BuildSaveHopLambda(const NYql::NNodes::TCoAggregate& aggregate, TExprContext& ctx);
  39. TExprNode::TPtr BuildLoadHopLambda(const NYql::NNodes::TCoAggregate& aggregate, TExprContext& ctx);
  40. } // namespace NYql::NHopping