1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #pragma once
- #include <yt/yql/plugin/bridge/interface.h>
- #include <util/generic/hash.h>
- #include <util/generic/string.h>
- #include <library/cpp/logger/log.h>
- #include <library/cpp/yt/string/guid.h>
- #include <library/cpp/yt/yson_string/string.h>
- #include <optional>
- namespace NYT::NYqlPlugin {
- using namespace NYson;
- ////////////////////////////////////////////////////////////////////////////////
- using TQueryId = TGuid;
- ////////////////////////////////////////////////////////////////////////////////
- class TYqlPluginOptions
- {
- public:
- TString MRJobBinary = "./mrjob";
- TString UdfDirectory;
- //! Mapping cluster name -> proxy address.
- THashMap<TString, TString> Clusters;
- std::optional<TString> DefaultCluster;
- TYsonString OperationAttributes;
- int MaxFilesSizeMb;
- int MaxFileCount;
- int DownloadFileRetryCount;
- TString YTTokenPath;
- THolder<TLogBackend> LogBackend;
- std::optional<TString> YqlPluginSharedLibrary;
- };
- struct TQueryResult
- {
- std::optional<TString> YsonResult;
- std::optional<TString> Plan;
- std::optional<TString> Statistics;
- std::optional<TString> Progress;
- std::optional<TString> TaskInfo;
- //! YSON representation of a YT error.
- std::optional<TString> YsonError;
- };
- struct TQueryFile
- {
- TStringBuf Name;
- TStringBuf Content;
- EQueryFileContentType Type;
- };
- //! This interface encapsulates YT <-> YQL integration.
- //! There are two major implementation: one of them is based
- //! on YQL code and another wraps the pure C bridge interface, which
- //! is implemented by a dynamic library.
- /*!
- * \note Thread affinity: any
- */
- struct IYqlPlugin
- {
- virtual TQueryResult Run(TQueryId queryId, TString impersonationUser, TString queryText, TYsonString settings, std::vector<TQueryFile> files) noexcept = 0;
- virtual TQueryResult GetProgress(TQueryId queryId) noexcept = 0;
- virtual ~IYqlPlugin() = default;
- };
- ////////////////////////////////////////////////////////////////////////////////
- Y_WEAK std::unique_ptr<IYqlPlugin> CreateYqlPlugin(TYqlPluginOptions& options) noexcept;
- ////////////////////////////////////////////////////////////////////////////////
- } // namespace NYT::NYqlPlugin
|