Skip to content

Commit 999d4ce

Browse files
Merge 528badc into 7182df1
2 parents 7182df1 + 528badc commit 999d4ce

7 files changed

Lines changed: 45 additions & 16 deletions

File tree

ydb/core/external_sources/external_source_factory.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ IExternalSourceFactory::TPtr CreateExternalSourceFactory(const std::vector<TStri
5454
{
5555
ToString(NYql::EDatabaseType::YT),
5656
CreateExternalDataSource(TString{NYql::YtProviderName}, {"NONE", "TOKEN"}, {}, hostnamePatternsRegEx)
57-
}
58-
});
57+
},
58+
{
59+
ToString(NYql::EDatabaseType::Greenplum),
60+
CreateExternalDataSource(TString{NYql::GenericProviderName}, {"MDB_BASIC", "BASIC"}, {"database_name", "mdb_cluster_id", "use_tls", "schema"}, hostnamePatternsRegEx)
61+
}});
5962
}
6063

6164
}

ydb/library/yql/providers/common/db_id_async_resolver/db_async_resolver.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum class EDatabaseType {
1414
DataStreams,
1515
ObjectStorage,
1616
PostgreSQL,
17+
Greenplum,
1718
YT
1819
};
1920

@@ -25,6 +26,8 @@ inline EDatabaseType DatabaseTypeFromDataSourceKind(NConnector::NApi::EDataSourc
2526
return EDatabaseType::ClickHouse;
2627
case NConnector::NApi::EDataSourceKind::YDB:
2728
return EDatabaseType::Ydb;
29+
case NConnector::NApi::EDataSourceKind::GREENPLUM:
30+
return EDatabaseType::Greenplum;
2831
default:
2932
ythrow yexception() << "Unknown data source kind: " << NConnector::NApi::EDataSourceKind_Name(dataSourceKind);
3033
}
@@ -38,6 +41,8 @@ inline NConnector::NApi::EDataSourceKind DatabaseTypeToDataSourceKind(EDatabaseT
3841
return NConnector::NApi::EDataSourceKind::CLICKHOUSE;
3942
case EDatabaseType::Ydb:
4043
return NConnector::NApi::EDataSourceKind::YDB;
44+
case EDatabaseType::Greenplum:
45+
return NConnector::NApi::EDataSourceKind::GREENPLUM;
4146
default:
4247
ythrow yexception() << "Unknown database type: " << ToString(databaseType);
4348
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace NYql::NDq {
3131
args.MaxKeysInRequest);
3232
};
3333

34-
for (auto& name : {"ClickHouseGeneric", "PostgreSqlGeneric", "YdbGeneric"}) {
34+
for (auto& name : {"ClickHouseGeneric", "PostgreSqlGeneric", "YdbGeneric", "GreenplumGeneric"}) {
3535
factory.RegisterSource<Generic::TSource>(name, readActorFactory);
3636
factory.RegisterLookupSource<Generic::TLookupSource>(name, lookupActorFactory);
3737
}

ydb/library/yql/providers/generic/connector/api/common/data_source.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ message TPostgreSQLDataSourceOptions {
5050
string schema = 1;
5151
}
5252

53+
// TGreenplumDataSourceOptions represents settings specific to Greenplum
54+
message TGreenplumDataSourceOptions {
55+
// Greenplum schema
56+
string schema = 1;
57+
}
58+
5359
// TClickhouseDataSourceOptions represents settings specific to Clickhouse
5460
message TClickhouseDataSourceOptions {
5561
}
@@ -83,5 +89,6 @@ message TDataSourceInstance {
8389
TPostgreSQLDataSourceOptions pg_options = 7;
8490
TClickhouseDataSourceOptions ch_options = 8;
8591
TS3DataSourceOptions s3_options = 9;
92+
TGreenplumDataSourceOptions gp_options = 10;
8693
}
8794
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace NYql {
192192
NYql::TGenericClusterConfig& clusterConfig) {
193193
using namespace NConnector::NApi;
194194

195-
if (clusterConfig.GetKind() == EDataSourceKind::YDB) {
195+
if (clusterConfig.GetKind() == EDataSourceKind::YDB || clusterConfig.GetKind() == EDataSourceKind::GREENPLUM) {
196196
clusterConfig.SetProtocol(EProtocol::NATIVE);
197197
return;
198198
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ namespace NYql {
173173
case NYql::NConnector::NApi::YDB:
174174
sourceType = "YdbGeneric";
175175
break;
176+
case NYql::NConnector::NApi::GREENPLUM:
177+
sourceType = "GreenplumGeneric";
178+
break;
176179
default:
177180
ythrow yexception() << "Data source kind is unknown or not specified";
178181
break;
@@ -207,6 +210,9 @@ namespace NYql {
207210
case NConnector::NApi::YDB:
208211
properties["SourceType"] = "Ydb";
209212
break;
213+
case NConnector::NApi::GREENPLUM:
214+
properties["SourceType"] = "Greenplum";
215+
break;
210216
case NConnector::NApi::DATA_SOURCE_KIND_UNSPECIFIED:
211217
break;
212218
default:

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,26 +313,34 @@ namespace NYql {
313313
*dsi->mutable_credentials()->mutable_token()->mutable_type() = "IAM";
314314
}
315315

316+
template<typename T>
317+
void SetSchema(T& request, const TGenericClusterConfig& clusterConfig) {
318+
TString schema;
319+
const auto it = clusterConfig.GetDataSourceOptions().find("schema");
320+
if (it != clusterConfig.GetDataSourceOptions().end()) {
321+
schema = it->second;
322+
}
323+
if (!schema) {
324+
schema = "public";
325+
}
326+
327+
request.set_schema(schema);
328+
}
329+
316330
void FillDataSourceOptions(NConnector::NApi::TDescribeTableRequest& request, const TGenericClusterConfig& clusterConfig) {
317331
const auto dataSourceKind = clusterConfig.GetKind();
318332
switch (dataSourceKind) {
319333
case NYql::NConnector::NApi::CLICKHOUSE:
320334
break;
321335
case NYql::NConnector::NApi::YDB:
322336
break;
337+
case NYql::NConnector::NApi::GREENPLUM: {
338+
auto* options = request.mutable_data_source_instance()->mutable_gp_options();
339+
SetSchema(*options, clusterConfig);
340+
} break;
323341
case NYql::NConnector::NApi::POSTGRESQL: {
324-
// for backward compability set schema "public" by default
325-
// TODO: simplify during https://st.yandex-team.ru/YQ-2494
326-
TString schema;
327-
const auto it = clusterConfig.GetDataSourceOptions().find("schema");
328-
if (it != clusterConfig.GetDataSourceOptions().end()) {
329-
schema = it->second;
330-
}
331-
if (!schema) {
332-
schema = "public";
333-
}
334-
335-
request.mutable_data_source_instance()->mutable_pg_options()->set_schema(schema);
342+
auto* options = request.mutable_data_source_instance()->mutable_pg_options();
343+
SetSchema(*options, clusterConfig);
336344
} break;
337345

338346
default:

0 commit comments

Comments
 (0)