Skip to content

Commit 1ba8c6e

Browse files
authored
YDB FQ: more support for Logging as an external data source (#12429)
1 parent e566060 commit 1ba8c6e

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

ydb/library/yql/providers/generic/actors/yql_generic_read_actor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ namespace NYql::NDq {
528528

529529
auto tokenProvider = CreateGenericTokenProvider(
530530
source.GetToken(),
531-
source.GetServiceAccountId(), source.GetServiceAccountIdSignature(),
531+
source.GetServiceAccountId(),
532+
source.GetServiceAccountIdSignature(),
532533
credentialsFactory);
533534

534535
const auto actor = new TGenericReadActor(

ydb/library/yql/providers/generic/actors/yql_generic_token_provider.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ namespace NYql::NDq {
1010
}
1111

1212
TGenericTokenProvider::TGenericTokenProvider(
13-
const TString& serviceAccountId, const TString& ServiceAccountIdSignature,
13+
const TString& serviceAccountId,
14+
const TString& serviceAccountIdSignature,
1415
const ISecuredServiceAccountCredentialsFactory::TPtr& credentialsFactory) {
1516
Y_ENSURE(!serviceAccountId.empty(), "No service account provided");
16-
Y_ENSURE(!ServiceAccountIdSignature.empty(), "No service account signature provided");
17+
Y_ENSURE(!serviceAccountIdSignature.empty(), "No service account signature provided");
1718
Y_ENSURE(credentialsFactory, "CredentialsFactory is not initialized");
1819

1920
auto structuredTokenJSON =
20-
TStructuredTokenBuilder().SetServiceAccountIdAuth(serviceAccountId, ServiceAccountIdSignature).ToJson();
21+
TStructuredTokenBuilder().SetServiceAccountIdAuth(serviceAccountId, serviceAccountIdSignature).ToJson();
2122

2223
Y_ENSURE(structuredTokenJSON, "empty structured token");
2324

@@ -58,7 +59,8 @@ namespace NYql::NDq {
5859
}
5960

6061
TGenericTokenProvider::TPtr
61-
CreateGenericTokenProvider(const TString& staticIamToken, const TString& serviceAccountId,
62+
CreateGenericTokenProvider(const TString& staticIamToken,
63+
const TString& serviceAccountId,
6264
const TString& serviceAccountIdSignature,
6365
const ISecuredServiceAccountCredentialsFactory::TPtr& credentialsFactory) {
6466
if (!staticIamToken.empty()) {

ydb/library/yql/providers/generic/actors/yql_generic_token_provider.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace NYql::NDq {
3232
TGenericTokenProvider::TPtr
3333
CreateGenericTokenProvider(
3434
const TString& staticIamToken,
35-
const TString& serviceAccountId, const TString& ServiceAccountIdSignature,
35+
const TString& serviceAccountId,
36+
const TString& serviceAccountIdSignature,
3637
const ISecuredServiceAccountCredentialsFactory::TPtr& credentialsFactory);
3738
} // namespace NYql::NDq

ydb/library/yql/providers/generic/provider/yql_generic_dq_integration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ namespace NYql {
164164
}
165165
}
166166

167-
// Managed YDB supports access via IAM token.
167+
// Managed YDB (including YDB underlying Logging) supports access via IAM token.
168168
// If exist, copy service account creds to obtain tokens during request execution phase.
169169
// If exists, copy previously created token.
170-
if (clusterConfig.kind() == NConnector::NApi::EDataSourceKind::YDB) {
170+
if (IsIn({NConnector::NApi::EDataSourceKind::YDB, NConnector::NApi::EDataSourceKind::LOGGING}, clusterConfig.kind())) {
171171
source.SetServiceAccountId(clusterConfig.GetServiceAccountId());
172172
source.SetServiceAccountIdSignature(clusterConfig.GetServiceAccountIdSignature());
173173
source.SetToken(State_->Types->Credentials->FindCredentialContent(

ydb/library/yql/providers/generic/provider/yql_generic_load_meta.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,17 @@ namespace NYql {
328328
request.set_schema(schema);
329329
}
330330

331-
void GetOracleServiceName(NYql::NConnector::NApi::TOracleDataSourceOptions& request, const TGenericClusterConfig& clusterConfig) {
331+
void SetOracleServiceName(NYql::NConnector::NApi::TOracleDataSourceOptions& options, const TGenericClusterConfig& clusterConfig) {
332332
const auto it = clusterConfig.GetDataSourceOptions().find("service_name");
333333
if (it != clusterConfig.GetDataSourceOptions().end()) {
334-
request.set_service_name(it->second);
334+
options.set_service_name(it->second);
335+
}
336+
}
337+
338+
void SetLoggingFolderId(NYql::NConnector::NApi::TLoggingDataSourceOptions& options, const TGenericClusterConfig& clusterConfig) {
339+
const auto it = clusterConfig.GetDataSourceOptions().find("folder_id");
340+
if (it != clusterConfig.GetDataSourceOptions().end()) {
341+
options.set_folder_id(it->second);
335342
}
336343
}
337344

@@ -356,10 +363,12 @@ namespace NYql {
356363
} break;
357364
case NYql::NConnector::NApi::ORACLE: {
358365
auto* options = request.mutable_data_source_instance()->mutable_oracle_options();
359-
GetOracleServiceName(*options, clusterConfig);
366+
SetOracleServiceName(*options, clusterConfig);
367+
} break;
368+
case NYql::NConnector::NApi::LOGGING: {
369+
auto* options = request.mutable_data_source_instance()->mutable_logging_options();
370+
SetLoggingFolderId(*options, clusterConfig);
360371
} break;
361-
case NYql::NConnector::NApi::LOGGING:
362-
break;
363372
default:
364373
ythrow yexception() << "Unexpected data source kind: '" << NYql::NConnector::NApi::EDataSourceKind_Name(dataSourceKind)
365374
<< "'";

0 commit comments

Comments
 (0)