Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YDB FQ: support Microsoft SQL Server as the external data source #5131

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 6 additions & 2 deletions ydb/core/external_sources/external_source_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ IExternalSourceFactory::TPtr CreateExternalSourceFactory(const std::vector<TStri
{
ToString(NYql::EDatabaseType::Greenplum),
CreateExternalDataSource(TString{NYql::GenericProviderName}, {"MDB_BASIC", "BASIC"}, {"database_name", "mdb_cluster_id", "use_tls", "schema"}, hostnamePatternsRegEx)
}});
},
{
ToString(NYql::EDatabaseType::MsSqlServer),
CreateExternalDataSource(TString{NYql::GenericProviderName}, {"BASIC"}, {"database_name", "protocol", "use_tls"}, hostnamePatternsRegEx)
Glebbs marked this conversation as resolved.
Show resolved Hide resolved
}});
}

}
}
Glebbs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ enum class EDatabaseType {
PostgreSQL,
YT,
MySQL,
Greenplum
Greenplum,
MsSqlServer
Glebbs marked this conversation as resolved.
Show resolved Hide resolved
Glebbs marked this conversation as resolved.
Show resolved Hide resolved
};

inline EDatabaseType DatabaseTypeFromDataSourceKind(NConnector::NApi::EDataSourceKind dataSourceKind) {
Expand All @@ -31,6 +32,8 @@ inline EDatabaseType DatabaseTypeFromDataSourceKind(NConnector::NApi::EDataSourc
return EDatabaseType::MySQL;
case NConnector::NApi::EDataSourceKind::GREENPLUM:
return EDatabaseType::Greenplum;
case NConnector::NApi::EDataSourceKind::MS_SQL_SERVER:
return EDatabaseType::MsSqlServer;
default:
ythrow yexception() << "Unknown data source kind: " << NConnector::NApi::EDataSourceKind_Name(dataSourceKind);
}
Expand All @@ -48,6 +51,8 @@ inline NConnector::NApi::EDataSourceKind DatabaseTypeToDataSourceKind(EDatabaseT
return NConnector::NApi::EDataSourceKind::MYSQL;
case EDatabaseType::Greenplum:
return NConnector::NApi::EDataSourceKind::GREENPLUM;
case EDatabaseType::MsSqlServer:
return NConnector::NApi::EDataSourceKind::MS_SQL_SERVER;
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", "GreenplumGeneric"}) {
for (auto& name : {"ClickHouseGeneric", "PostgreSqlGeneric", "YdbGeneric", "MySqlGeneric", "GreenplumGeneric", "MsSqlServerGeneric"}) {
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 @@ -178,6 +178,8 @@ namespace NYql {
break;
case NYql::NConnector::NApi::GREENPLUM:
sourceType = "GreenplumGeneric";
case NYql::NConnector::NApi::MS_SQL_SERVER:
sourceType = "MsSqlServerGeneric";
break;
default:
ythrow yexception() << "Data source kind is unknown or not specified";
Expand Down Expand Up @@ -219,6 +221,9 @@ namespace NYql {
case NConnector::NApi::GREENPLUM:
properties["SourceType"] = "Greenplum";
break;
case NConnector::NApi::MS_SQL_SERVER:
properties["SourceType"] = "MsSqlServer";
break;
case NConnector::NApi::DATA_SOURCE_KIND_UNSPECIFIED:
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ namespace NYql {
auto* options = request.mutable_data_source_instance()->mutable_gp_options();
SetSchema(*options, clusterConfig);
} break;
case NYql::NConnector::NApi::MS_SQL_SERVER:
break;
case NYql::NConnector::NApi::POSTGRESQL: {
auto* options = request.mutable_data_source_instance()->mutable_pg_options();
SetSchema(*options, clusterConfig);
Expand Down Expand Up @@ -386,6 +388,9 @@ namespace NYql {
case NYql::NConnector::NApi::POSTGRESQL:
dbNameTarget = "postgres";
break;
case NYql::NConnector::NApi::MS_SQL_SERVER:
dbNameTarget = "mssqlserver";
break;
default:
ythrow yexception() << "You must provide database name explicitly for data source kind: '"
<< NYql::NConnector::NApi::EDataSourceKind_Name(dataSourceKind) << "'";
Expand Down
Loading