Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ydb/core/external_sources/external_source_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ IExternalSourceFactory::TPtr CreateExternalSourceFactory(const std::vector<TStri
{
ToString(NYql::EDatabaseType::YT),
CreateExternalDataSource(TString{NYql::YtProviderName}, {"NONE", "TOKEN"}, {}, hostnamePatternsRegEx)
}
});
},
{
ToString(NYql::EDatabaseType::Greenplum),
CreateExternalDataSource(TString{NYql::GenericProviderName}, {"MDB_BASIC", "BASIC"}, {"database_name", "mdb_cluster_id", "use_tls", "schema"}, hostnamePatternsRegEx)
}});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ enum class EDatabaseType {
ObjectStorage,
PostgreSQL,
YT,
MySQL
MySQL,
Greenplum
};

inline EDatabaseType DatabaseTypeFromDataSourceKind(NConnector::NApi::EDataSourceKind dataSourceKind) {
Expand All @@ -28,6 +29,8 @@ inline EDatabaseType DatabaseTypeFromDataSourceKind(NConnector::NApi::EDataSourc
return EDatabaseType::Ydb;
case NConnector::NApi::EDataSourceKind::MYSQL:
return EDatabaseType::MySQL;
case NConnector::NApi::EDataSourceKind::GREENPLUM:
return EDatabaseType::Greenplum;
default:
ythrow yexception() << "Unknown data source kind: " << NConnector::NApi::EDataSourceKind_Name(dataSourceKind);
}
Expand All @@ -43,6 +46,8 @@ inline NConnector::NApi::EDataSourceKind DatabaseTypeToDataSourceKind(EDatabaseT
return NConnector::NApi::EDataSourceKind::YDB;
case EDatabaseType::MySQL:
return NConnector::NApi::EDataSourceKind::MYSQL;
case EDatabaseType::Greenplum:
return NConnector::NApi::EDataSourceKind::GREENPLUM;
default:
ythrow yexception() << "Unknown database type: " << ToString(databaseType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace NYql::NDq {
args.MaxKeysInRequest);
};

for (auto& name : {"ClickHouseGeneric", "PostgreSqlGeneric", "YdbGeneric", "MySqlGeneric"}) {
for (auto& name : {"ClickHouseGeneric", "PostgreSqlGeneric", "YdbGeneric", "MySqlGeneric", "GreenplumGeneric"}) {
factory.RegisterSource<Generic::TSource>(name, readActorFactory);
factory.RegisterLookupSource<Generic::TLookupSource>(name, lookupActorFactory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ message TS3DataSourceOptions {
string bucket = 2;
}

// TGreenplumDataSourceOptions represents settings specific to Greenplum
message TGreenplumDataSourceOptions {
// Greenplum schema
string schema = 1;
}

// TDataSourceInstance helps to identify the instance of a data source to redirect request to.
message TDataSourceInstance {
// Data source kind
Expand All @@ -83,5 +89,6 @@ message TDataSourceInstance {
TPostgreSQLDataSourceOptions pg_options = 7;
TClickhouseDataSourceOptions ch_options = 8;
TS3DataSourceOptions s3_options = 9;
TGreenplumDataSourceOptions gp_options = 10;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ namespace NYql {
NYql::TGenericClusterConfig& clusterConfig) {
using namespace NConnector::NApi;

if (clusterConfig.GetKind() == EDataSourceKind::YDB) {
clusterConfig.SetProtocol(EProtocol::NATIVE);
return;
}

if (clusterConfig.GetKind() == EDataSourceKind::MYSQL) {
if (IsIn({EDataSourceKind::GREENPLUM, EDataSourceKind::YDB, EDataSourceKind::MYSQL}, clusterConfig.GetKind())) {
clusterConfig.SetProtocol(EProtocol::NATIVE);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ namespace NYql {
case NYql::NConnector::NApi::YDB:
sourceType = "YdbGeneric";
break;
case NYql::NConnector::NApi::GREENPLUM:
sourceType = "GreenplumGeneric";
break;
default:
ythrow yexception() << "Data source kind is unknown or not specified";
break;
Expand Down Expand Up @@ -213,6 +216,9 @@ namespace NYql {
case NConnector::NApi::YDB:
properties["SourceType"] = "Ydb";
break;
case NConnector::NApi::GREENPLUM:
properties["SourceType"] = "Greenplum";
break;
case NConnector::NApi::DATA_SOURCE_KIND_UNSPECIFIED:
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,20 @@ namespace NYql {
*dsi->mutable_credentials()->mutable_token()->mutable_type() = "IAM";
}

template <typename T>
void SetSchema(T& request, const TGenericClusterConfig& clusterConfig) {
TString schema;
const auto it = clusterConfig.GetDataSourceOptions().find("schema");
if (it != clusterConfig.GetDataSourceOptions().end()) {
schema = it->second;
}
if (!schema) {
schema = "public";
}

request.set_schema(schema);
}

void FillDataSourceOptions(NConnector::NApi::TDescribeTableRequest& request, const TGenericClusterConfig& clusterConfig) {
const auto dataSourceKind = clusterConfig.GetKind();
switch (dataSourceKind) {
Expand All @@ -322,19 +336,13 @@ namespace NYql {
break;
case NYql::NConnector::NApi::MYSQL:
break;
case NYql::NConnector::NApi::GREENPLUM: {
auto* options = request.mutable_data_source_instance()->mutable_gp_options();
SetSchema(*options, clusterConfig);
} break;
case NYql::NConnector::NApi::POSTGRESQL: {
// for backward compability set schema "public" by default
// TODO: simplify during https://st.yandex-team.ru/YQ-2494
TString schema;
const auto it = clusterConfig.GetDataSourceOptions().find("schema");
if (it != clusterConfig.GetDataSourceOptions().end()) {
schema = it->second;
}
if (!schema) {
schema = "public";
}

request.mutable_data_source_instance()->mutable_pg_options()->set_schema(schema);
auto* options = request.mutable_data_source_instance()->mutable_pg_options();
SetSchema(*options, clusterConfig);
} break;

default:
Expand Down