Skip to content

Commit 7343abb

Browse files
committed
YQ-4084 Add AllExternalDataSourcesAreAvailable to QueryServiceConfig (#18042)
1 parent 376860c commit 7343abb

File tree

13 files changed

+20
-44
lines changed

13 files changed

+20
-44
lines changed

ydb/core/external_sources/external_source_factory.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ namespace {
1616
struct TExternalSourceFactory : public IExternalSourceFactory {
1717
TExternalSourceFactory(
1818
const TMap<TString, IExternalSource::TPtr>& sources,
19+
bool allExternalDataSourcesAreAvailable,
1920
const std::set<TString>& availableExternalDataSources)
2021
: Sources(sources)
22+
, AllExternalDataSourcesAreAvailable(allExternalDataSourcesAreAvailable)
2123
, AvailableExternalDataSources(availableExternalDataSources)
2224
{}
2325

@@ -26,14 +28,15 @@ struct TExternalSourceFactory : public IExternalSourceFactory {
2628
if (it == Sources.end()) {
2729
throw TExternalSourceException() << "External source with type " << type << " was not found";
2830
}
29-
if (!AvailableExternalDataSources.contains(type)) {
31+
if (!AllExternalDataSourcesAreAvailable && !AvailableExternalDataSources.contains(type)) {
3032
throw TExternalSourceException() << "External source with type " << type << " is disabled. Please contact your system administrator to enable it";
3133
}
3234
return it->second;
3335
}
3436

3537
private:
3638
const TMap<TString, IExternalSource::TPtr> Sources;
39+
bool AllExternalDataSourcesAreAvailable;
3740
const std::set<TString> AvailableExternalDataSources;
3841
};
3942

@@ -45,6 +48,7 @@ IExternalSourceFactory::TPtr CreateExternalSourceFactory(const std::vector<TStri
4548
std::shared_ptr<NYql::ISecuredServiceAccountCredentialsFactory> credentialsFactory,
4649
bool enableInfer,
4750
bool allowLocalFiles,
51+
bool allExternalDataSourcesAreAvailable,
4852
const std::set<TString>& availableExternalDataSources) {
4953
std::vector<TRegExMatch> hostnamePatternsRegEx(hostnamePatterns.begin(), hostnamePatterns.end());
5054
return MakeIntrusive<TExternalSourceFactory>(TMap<TString, IExternalSource::TPtr>{
@@ -93,6 +97,7 @@ IExternalSourceFactory::TPtr CreateExternalSourceFactory(const std::vector<TStri
9397
CreateExternalDataSource(TString{NYql::SolomonProviderName}, {"NONE", "TOKEN"}, {"use_ssl", "grpc_port"}, hostnamePatternsRegEx)
9498
}
9599
},
100+
allExternalDataSourcesAreAvailable,
96101
availableExternalDataSources);
97102
}
98103

ydb/core/external_sources/external_source_factory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ IExternalSourceFactory::TPtr CreateExternalSourceFactory(const std::vector<TStri
1818
std::shared_ptr<NYql::ISecuredServiceAccountCredentialsFactory> credentialsFactory = nullptr,
1919
bool enableInfer = false,
2020
bool allowLocalFiles = false,
21+
bool allExternalDataSourcesAreAvailable = true,
2122
const std::set<TString>& availableExternalDataSources = {});
2223

2324
}

ydb/core/grpc_services/rpc_describe_external_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ bool ConvertContent(
3636
google::protobuf::Map<TProtoStringType, TProtoStringType>& out,
3737
TIssues& issues
3838
) {
39-
const auto externalSourceFactory = NExternalSource::CreateExternalSourceFactory({}, nullptr, 50000, nullptr, false, false, NYql::GetAllExternalDataSourceTypes());
39+
const auto externalSourceFactory = NExternalSource::CreateExternalSourceFactory({}, nullptr, 50000, nullptr, false, false, true, NYql::GetAllExternalDataSourceTypes());
4040
try {
4141
const auto source = externalSourceFactory->GetOrCreate(sourceType);
4242
for (const auto& [key, items] : source->GetParameters(in)) {

ydb/core/kqp/host/kqp_host.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,7 @@ class TKqpHost : public IKqpHost {
11721172
FederatedQuerySetup ? FederatedQuerySetup->CredentialsFactory : nullptr,
11731173
Config->FeatureFlags.GetEnableExternalSourceSchemaInference(),
11741174
FederatedQuerySetup->S3GatewayConfig.GetAllowLocalFiles(),
1175+
QueryServiceConfig.GetAllExternalDataSourcesAreAvailable(),
11751176
std::set<TString>(availableExternalDataSources.cbegin(), availableExternalDataSources.cend()));
11761177
}
11771178
}

ydb/core/kqp/ut/federated_query/common/common.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ namespace NKikimr::NKqp::NFederatedQueryTest {
4141
if (!appConfig) {
4242
appConfig.emplace();
4343
}
44-
appConfig->MutableQueryServiceConfig()->AddAvailableExternalDataSources("ObjectStorage");
45-
appConfig->MutableQueryServiceConfig()->AddAvailableExternalDataSources("ClickHouse");
46-
appConfig->MutableQueryServiceConfig()->AddAvailableExternalDataSources("PostgreSQL");
47-
appConfig->MutableQueryServiceConfig()->AddAvailableExternalDataSources("MySQL");
48-
appConfig->MutableQueryServiceConfig()->AddAvailableExternalDataSources("Ydb");
44+
appConfig->MutableQueryServiceConfig()->SetAllExternalDataSourcesAreAvailable(true);
4945

5046
auto settings = TKikimrSettings();
5147

ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6613,7 +6613,6 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
66136613
Y_UNIT_TEST(CreateExternalDataSource) {
66146614
NKikimrConfig::TAppConfig appCfg;
66156615
appCfg.MutableQueryServiceConfig()->AddHostnamePatterns("my-bucket");
6616-
appCfg.MutableQueryServiceConfig()->AddAvailableExternalDataSources("ObjectStorage");
66176616

66186617
TKikimrRunner kikimr(appCfg);
66196618
kikimr.GetTestServer().GetRuntime()->GetAppData(0).FeatureFlags.SetEnableExternalDataSources(true);
@@ -6696,6 +6695,7 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
66966695

66976696
Y_UNIT_TEST(DisableS3ExternalDataSource) {
66986697
NKikimrConfig::TAppConfig appCfg;
6698+
appCfg.MutableQueryServiceConfig()->SetAllExternalDataSourcesAreAvailable(false);
66996699
appCfg.MutableQueryServiceConfig()->AddAvailableExternalDataSources("PostgreSQL");
67006700
TKikimrRunner kikimr(appCfg);
67016701
kikimr.GetTestServer().GetRuntime()->GetAppData(0).FeatureFlags.SetEnableExternalDataSources(true);

ydb/core/protos/config.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,8 @@ message TQueryServiceConfig {
10771077
optional uint64 ProgressStatsPeriodMs = 14 [default = 0]; // 0 = disabled
10781078
optional uint32 QueryTimeoutDefaultSeconds = 19 [default = 1800];
10791079
optional bool EnableMatchRecognize = 20 [default = false];
1080-
repeated string AvailableExternalDataSources = 22;
1080+
repeated string AvailableExternalDataSources = 22; // Ignored if AllExternalDataSourcesAreAvailable is true
1081+
optional bool AllExternalDataSourcesAreAvailable = 23 [default = true];
10811082
}
10821083

10831084
// Config describes immediate controls and allows

ydb/core/tx/schemeshard/schemeshard_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7287,6 +7287,7 @@ void TSchemeShard::ApplyConsoleConfigs(const NKikimrConfig::TAppConfig& appConfi
72877287
nullptr,
72887288
appConfig.GetFeatureFlags().GetEnableExternalSourceSchemaInference(),
72897289
appConfig.GetQueryServiceConfig().GetS3().GetAllowLocalFiles(),
7290+
appConfig.GetQueryServiceConfig().GetAllExternalDataSourcesAreAvailable(),
72907291
std::set<TString>(availableExternalDataSources.cbegin(), availableExternalDataSources.cend())
72917292
);
72927293
}

ydb/core/tx/schemeshard/ut_helpers/test_env.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,17 +1026,7 @@ void NSchemeShardUT_Private::TTestEnv::BootTxAllocator(NActors::TTestActorRuntim
10261026
NKikimrConfig::TAppConfig NSchemeShardUT_Private::TTestEnv::GetAppConfig() const {
10271027
NKikimrConfig::TAppConfig appConfig;
10281028
auto* queryServiceConfig = appConfig.MutableQueryServiceConfig();
1029-
queryServiceConfig->AddAvailableExternalDataSources("ObjectStorage");
1030-
queryServiceConfig->AddAvailableExternalDataSources("ClickHouse");
1031-
queryServiceConfig->AddAvailableExternalDataSources("PostgreSQL");
1032-
queryServiceConfig->AddAvailableExternalDataSources("MySQL");
1033-
queryServiceConfig->AddAvailableExternalDataSources("Ydb");
1034-
queryServiceConfig->AddAvailableExternalDataSources("YT");
1035-
queryServiceConfig->AddAvailableExternalDataSources("Greenplum");
1036-
queryServiceConfig->AddAvailableExternalDataSources("MsSQLServer");
1037-
queryServiceConfig->AddAvailableExternalDataSources("Oracle");
1038-
queryServiceConfig->AddAvailableExternalDataSources("Logging");
1039-
queryServiceConfig->AddAvailableExternalDataSources("Solomon");
1029+
queryServiceConfig->SetAllExternalDataSourcesAreAvailable(true);
10401030
return appConfig;
10411031
}
10421032

ydb/core/viewer/viewer_describe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class TJsonDescribe : public TViewerPipeClient {
314314
return;
315315
}
316316

317-
NExternalSource::IExternalSourceFactory::TPtr externalSourceFactory{NExternalSource::CreateExternalSourceFactory({}, nullptr, 50000, nullptr, false, false, NYql::GetAllExternalDataSourceTypes())};
317+
NExternalSource::IExternalSourceFactory::TPtr externalSourceFactory{NExternalSource::CreateExternalSourceFactory({}, nullptr, 50000, nullptr, false, false, true, NYql::GetAllExternalDataSourceTypes())};
318318
NJson::TJsonValue root;
319319
const auto& sourceType = DescribeResult->GetPathDescription().GetExternalTableDescription().GetSourceType();
320320
try {

0 commit comments

Comments
 (0)