123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #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:
- TYsonString SingletonsConfig;
- TYsonString GatewayConfig;
- TYsonString FileStorageConfig;
- TYsonString OperationAttributes;
- 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
|