aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony-Romanov <150126326+Tony-Romanov@users.noreply.github.com>2024-12-13 10:32:01 +0100
committerGitHub <noreply@github.com>2024-12-13 12:32:01 +0300
commit812b8cf221f0d849d71cadf43e63e2a7177fc2d9 (patch)
tree5c82d6172c1980eff7937728d2a47114003df7eb
parent7782482c95220d639135c7992e46deaa4b372a45 (diff)
downloadydb-812b8cf221f0d849d71cadf43e63e2a7177fc2d9.tar.gz
Add extra credentials for YQL plugin. (#12584)
-rw-r--r--ydb/library/yql/yt/bridge/interface.h5
-rw-r--r--ydb/library/yql/yt/dynamic/impl.cpp9
-rw-r--r--ydb/library/yql/yt/native/plugin.cpp18
-rw-r--r--ydb/library/yql/yt/plugin.h2
4 files changed, 23 insertions, 11 deletions
diff --git a/ydb/library/yql/yt/bridge/interface.h b/ydb/library/yql/yt/bridge/interface.h
index 43f3feddb4..19c8bea9c9 100644
--- a/ydb/library/yql/yt/bridge/interface.h
+++ b/ydb/library/yql/yt/bridge/interface.h
@@ -128,13 +128,14 @@ using TFuncBridgeRun = TBridgeQueryResult*(
TBridgeYqlPlugin* plugin,
const char* queryId,
const char* user,
- const char* token,
const char* queryText,
const char* settings,
int settingsLength,
const TBridgeQueryFile* files,
int fileCount,
- int executeMode);
+ int executeMode,
+ const char* credentials,
+ int credentialsLength);
using TFuncBridgeGetUsedClusters = TBridgeClustersResult*(
TBridgeYqlPlugin* plugin,
const char* queryText,
diff --git a/ydb/library/yql/yt/dynamic/impl.cpp b/ydb/library/yql/yt/dynamic/impl.cpp
index 11841c6af9..db5cd51f1f 100644
--- a/ydb/library/yql/yt/dynamic/impl.cpp
+++ b/ydb/library/yql/yt/dynamic/impl.cpp
@@ -15,7 +15,7 @@ extern "C" {
ssize_t BridgeGetAbiVersion()
{
- return 4; // EYqlPluginAbiVersion::TemporaryTokens
+ return 5; // EYqlPluginAbiVersion::Credentials
}
TBridgeYqlPlugin* BridgeCreateYqlPlugin(const TBridgeYqlPluginOptions* bridgeOptions)
@@ -135,13 +135,14 @@ TBridgeQueryResult* BridgeRun(
TBridgeYqlPlugin* plugin,
const char* queryId,
const char* user,
- const char* token,
const char* queryText,
const char* settings,
int settingsLength,
const TBridgeQueryFile* bridgeFiles,
int bridgeFileCount,
- int executeMode)
+ int executeMode,
+ const char* credentials,
+ int credentialsLength)
{
static const auto EmptyMap = TYsonString(TString("{}"));
@@ -161,7 +162,7 @@ TBridgeQueryResult* BridgeRun(
auto result = nativePlugin->Run(
NYT::TGuid::FromString(queryId),
TString(user),
- TString(token),
+ TYsonString(TString(credentials, credentialsLength)),
TString(queryText),
settings ? TYsonString(TString(settings, settingsLength)) : EmptyMap,
files,
diff --git a/ydb/library/yql/yt/native/plugin.cpp b/ydb/library/yql/yt/native/plugin.cpp
index 58b1165e09..48fd34de60 100644
--- a/ydb/library/yql/yt/native/plugin.cpp
+++ b/ydb/library/yql/yt/native/plugin.cpp
@@ -453,7 +453,7 @@ public:
TQueryResult GuardedRun(
TQueryId queryId,
TString user,
- TString token,
+ TYsonString credentialsStr,
TString queryText,
TYsonString settings,
std::vector<TQueryFile> files,
@@ -465,7 +465,17 @@ public:
ActiveQueriesProgress_[queryId].Program = program;
}
- program->AddCredentials({{"default_yt", NYql::TCredential("yt", "", token)}});
+ TVector<std::pair<TString, NYql::TCredential>> credentials;
+ const auto credentialsMap = NodeFromYsonString(credentialsStr.ToString()).AsMap();
+ credentials.reserve(credentialsMap.size());
+ for (const auto& item : credentialsMap) {
+ credentials.emplace_back(item.first, NYql::TCredential {
+ item.second.HasKey("category") ? item.second.ChildAsString("category") : "",
+ item.second.HasKey("subcategory") ? item.second.ChildAsString("subcategory") : "",
+ item.second.HasKey("content") ? item.second.ChildAsString("content") : ""
+ });
+ }
+ program->AddCredentials(credentials);
program->SetOperationAttrsYson(PatchQueryAttributes(OperationAttributes_, settings));
auto defaultQueryCluster = DefaultCluster_;
@@ -589,14 +599,14 @@ public:
TQueryResult Run(
TQueryId queryId,
TString user,
- TString token,
+ TYsonString credentials,
TString queryText,
TYsonString settings,
std::vector<TQueryFile> files,
int executeMode) noexcept override
{
try {
- auto result = GuardedRun(queryId, user, token, queryText, settings, files, executeMode);
+ auto result = GuardedRun(queryId, user, credentials, queryText, settings, files, executeMode);
if (result.YsonError) {
ExtractQuery(queryId);
}
diff --git a/ydb/library/yql/yt/plugin.h b/ydb/library/yql/yt/plugin.h
index 207705979d..6715d316c5 100644
--- a/ydb/library/yql/yt/plugin.h
+++ b/ydb/library/yql/yt/plugin.h
@@ -89,7 +89,7 @@ struct IYqlPlugin
virtual TQueryResult Run(
TQueryId queryId,
TString user,
- TString token,
+ NYson::TYsonString credentials,
TString queryText,
NYson::TYsonString settings,
std::vector<TQueryFile> files,