yql_udf_resolver.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "yql_user_data.h"
  3. #include <yql/essentials/providers/common/proto/udf_resolver.pb.h>
  4. #include <yql/essentials/public/issue/yql_issue.h>
  5. #include <util/generic/maybe.h>
  6. #include <util/generic/vector.h>
  7. namespace NYql {
  8. class TTypeAnnotationNode;
  9. struct TUserDataBlock;
  10. struct TExprContext;
  11. struct TFilePathWithMd5 {
  12. TString Path;
  13. TString Md5;
  14. explicit TFilePathWithMd5(const TString& path = "", const TString& md5 = "")
  15. : Path(path)
  16. , Md5(md5)
  17. {
  18. }
  19. TFilePathWithMd5& operator=(const TFilePathWithMd5& other) = default;
  20. };
  21. class IUdfResolver : public TThrRefBase {
  22. public:
  23. using TPtr = TIntrusiveConstPtr<IUdfResolver>;
  24. virtual ~IUdfResolver() = default;
  25. struct TFunction {
  26. // input
  27. TPosition Pos;
  28. TString Name;
  29. TString TypeConfig;
  30. const TTypeAnnotationNode* UserType = nullptr;
  31. THashMap<TString, TString> SecureParams;
  32. // output
  33. TString NormalizedName;
  34. const TTypeAnnotationNode* NormalizedUserType = nullptr;
  35. const TTypeAnnotationNode* RunConfigType = nullptr;
  36. const TTypeAnnotationNode* CallableType = nullptr;
  37. bool SupportsBlocks = false;
  38. bool IsStrict = false;
  39. };
  40. struct TImport {
  41. // input
  42. TPosition Pos;
  43. TString FileAlias;
  44. const TUserDataBlock* Block = nullptr;
  45. // output
  46. TMaybe<TVector<TString>> Modules;
  47. };
  48. /*
  49. Returns nothing if module is not a system one
  50. Always returns frozen path
  51. */
  52. virtual TMaybe<TFilePathWithMd5> GetSystemModulePath(const TStringBuf& moduleName) const = 0;
  53. virtual bool LoadMetadata(const TVector<TImport*>& imports,
  54. const TVector<TFunction*>& functions, TExprContext& ctx) const = 0;
  55. virtual TResolveResult LoadRichMetadata(const TVector<TImport>& imports) const = 0;
  56. virtual bool ContainsModule(const TStringBuf& moduleName) const = 0;
  57. };
  58. TResolveResult LoadRichMetadata(const IUdfResolver& resolver, const TVector<TUserDataBlock>& blocks);
  59. TResolveResult LoadRichMetadata(const IUdfResolver& resolver, const TVector<TString>& paths);
  60. }