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 MySQL as an external data source #4951

Merged
merged 5 commits into from
May 29, 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
4 changes: 4 additions & 0 deletions ydb/core/external_sources/external_source_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ IExternalSourceFactory::TPtr CreateExternalSourceFactory(const std::vector<TStri
ToString(NYql::EDatabaseType::PostgreSQL),
CreateExternalDataSource(TString{NYql::GenericProviderName}, {"MDB_BASIC", "BASIC"}, {"database_name", "protocol", "mdb_cluster_id", "use_tls", "schema"}, hostnamePatternsRegEx)
},
{
ToString(NYql::EDatabaseType::MySQL),
CreateExternalDataSource(TString{NYql::GenericProviderName}, {"MDB_BASIC", "BASIC"}, {"database_name", "protocol", "mdb_cluster_id", "use_tls"}, hostnamePatternsRegEx)
vitalyisaev2 marked this conversation as resolved.
Show resolved Hide resolved
},
{
ToString(NYql::EDatabaseType::Ydb),
CreateExternalDataSource(TString{NYql::GenericProviderName}, {"BASIC", "SERVICE_ACCOUNT"}, {"database_name", "use_tls", "database_id"}, hostnamePatternsRegEx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ enum class EDatabaseType {
DataStreams,
ObjectStorage,
PostgreSQL,
YT
YT,
MySQL
};

inline EDatabaseType DatabaseTypeFromDataSourceKind(NConnector::NApi::EDataSourceKind dataSourceKind) {
Expand All @@ -25,6 +26,8 @@ inline EDatabaseType DatabaseTypeFromDataSourceKind(NConnector::NApi::EDataSourc
return EDatabaseType::ClickHouse;
case NConnector::NApi::EDataSourceKind::YDB:
return EDatabaseType::Ydb;
case NConnector::NApi::EDataSourceKind::MYSQL:
return EDatabaseType::MySQL;
default:
ythrow yexception() << "Unknown data source kind: " << NConnector::NApi::EDataSourceKind_Name(dataSourceKind);
}
Expand All @@ -38,6 +41,8 @@ inline NConnector::NApi::EDataSourceKind DatabaseTypeToDataSourceKind(EDatabaseT
return NConnector::NApi::EDataSourceKind::CLICKHOUSE;
case EDatabaseType::Ydb:
return NConnector::NApi::EDataSourceKind::YDB;
case EDatabaseType::MySQL:
return NConnector::NApi::EDataSourceKind::MYSQL;
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"}) {
for (auto& name : {"ClickHouseGeneric", "PostgreSqlGeneric", "YdbGeneric", "MySqlGeneric"}) {
factory.RegisterSource<Generic::TSource>(name, readActorFactory);
factory.RegisterLookupSource<Generic::TLookupSource>(name, lookupActorFactory);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "yql_generic_dq_integration.h"

#include "ydb/library/yql/providers/generic/connector/api/common/data_source.pb.h"
#include "yql_generic_mkql_compiler.h"
#include "yql_generic_predicate_pushdown.h"

Expand Down Expand Up @@ -170,6 +171,9 @@ namespace NYql {
case NYql::NConnector::NApi::POSTGRESQL:
sourceType = "PostgreSqlGeneric";
break;
case NYql::NConnector::NApi::MYSQL:
sourceType = "MySqlGeneric";
break;
case NYql::NConnector::NApi::YDB:
sourceType = "YdbGeneric";
break;
Expand Down Expand Up @@ -204,6 +208,9 @@ namespace NYql {
case NConnector::NApi::POSTGRESQL:
properties["SourceType"] = "PostgreSql";
break;
case NConnector::NApi::MYSQL:
properties["SourceType"] = "MySql";
break;
case NConnector::NApi::YDB:
properties["SourceType"] = "Ydb";
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "ydb/library/yql/providers/generic/connector/api/common/data_source.pb.h"
vitalyisaev2 marked this conversation as resolved.
Show resolved Hide resolved
#include "yql_generic_provider_impl.h"

#include <library/cpp/json/json_reader.h>
Expand Down Expand Up @@ -320,6 +321,8 @@ namespace NYql {
break;
case NYql::NConnector::NApi::YDB:
break;
case NYql::NConnector::NApi::MYSQL:
break;
case NYql::NConnector::NApi::POSTGRESQL: {
// for backward compability set schema "public" by default
// TODO: simplify during https://st.yandex-team.ru/YQ-2494
Expand Down
Loading