request.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include <yql/essentials/ast/yql_expr.h>
  3. #include <yql/essentials/minikql/mkql_program_builder.h>
  4. #include <yql/essentials/providers/common/mkql/yql_type_mkql.h>
  5. #include <unordered_map>
  6. namespace NYql {
  7. class TKernelRequestBuilder {
  8. public:
  9. enum class EUnaryOp {
  10. Not,
  11. Size,
  12. Minus,
  13. Abs,
  14. Just
  15. };
  16. enum class EBinaryOp {
  17. And = 0,
  18. Or,
  19. Xor,
  20. Add,
  21. Sub,
  22. Mul,
  23. Div,
  24. Mod,
  25. StartsWith,
  26. EndsWith,
  27. StringContains,
  28. Equals,
  29. NotEquals,
  30. Less,
  31. LessOrEqual,
  32. Greater,
  33. GreaterOrEqual,
  34. Coalesce
  35. };
  36. TKernelRequestBuilder(const NKikimr::NMiniKQL::IFunctionRegistry& functionRegistry);
  37. ~TKernelRequestBuilder();
  38. ui32 AddUnaryOp(EUnaryOp op, const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* retType);
  39. ui32 AddBinaryOp(EBinaryOp op, const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* arg2Type, const TTypeAnnotationNode* retType);
  40. ui32 AddIf(const TTypeAnnotationNode* conditionType, const TTypeAnnotationNode* thenType, const TTypeAnnotationNode* elseType);
  41. ui32 Udf(const TString& name, bool isPolymorphic, const TTypeAnnotationNode::TListType& argTypes, const TTypeAnnotationNode* retType);
  42. ui32 AddScalarApply(const TExprNode& lambda, const TTypeAnnotationNode::TListType& argTypes, TExprContext& ctx);
  43. // (json/json?,utf8)->bool/bool?
  44. ui32 JsonExists(const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* arg2Type, const TTypeAnnotationNode* retType);
  45. ui32 JsonValue(const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* arg2Type, const TTypeAnnotationNode* retType);
  46. TString Serialize();
  47. private:
  48. NKikimr::NMiniKQL::TRuntimeNode MakeArg(const TTypeAnnotationNode* type);
  49. NKikimr::NMiniKQL::TBlockType* MakeType(const TTypeAnnotationNode* type);
  50. private:
  51. NKikimr::NMiniKQL::TScopedAlloc Alloc_;
  52. const NKikimr::NMiniKQL::TTypeEnvironment Env_;
  53. NKikimr::NMiniKQL::TProgramBuilder Pb_;
  54. std::vector<NKikimr::NMiniKQL::TRuntimeNode> Items_;
  55. std::vector<NKikimr::NMiniKQL::TRuntimeNode> ArgsItems_;
  56. NCommon::TMemoizedTypesMap TypesMemoization_;
  57. std::unordered_map<const TTypeAnnotationNode*, NKikimr::NMiniKQL::TRuntimeNode> CachedArgs_;
  58. };
  59. }