-
Notifications
You must be signed in to change notification settings - Fork 696
add external data source public API for description #14438
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
add external data source public API for description #14438
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Ydb.Scheme.Entry self = 1; | ||
optional string source_type = 2; | ||
optional string location = 3; | ||
optional string installation = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installation сейчас не используется, предлагаю когда имплементация появится, то добавить это поле
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрал
optional string data_source_path = 3; | ||
optional string location = 4; | ||
repeated ColumnMeta columns = 5; | ||
optional bytes content = 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content лучше развернуть в какой нибудь json/map<string, string> или же any с конкретными protobuf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Развернул в map<string, string>.
Для полноты:
- content - это NKikimrExternalSources::TGeneral, что видно здесь
- в TGeneral помимо map<string, string> лежит ещё и location, но он был добавлен для валидации wildcard'ов, возможно, его и не нужно в description'е отдавать (тем более, в description external table уже есть location (см. поле номер 4)) @dorooleg, @GrigoriyPA
optional string source_type = 2; | ||
optional string location = 3; | ||
optional string installation = 4; | ||
optional ExternalAuthorization authorization = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно authorization стоит развернуть и переместить в properties
. Между этими именами не будет пересечений это гарантируется на уровне ddl сейчас
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Развернул Authorization в общий map<string, string> properties. Кажется, такое описание лучше ложится на:
- YQL для создания external data source. Смотри доку, там, по сути,
CREATE EXTERNAL DATA SOURCE
и куча структурно не связанных друг с другом параметров вWITH
блоке. Такая независимость может быть удобна и предусмотрена by design (@dorooleg ?), чтобы легче было добавлять новые внешние источники данных. - внутреннее представление этих параметров перед разворачиванием их в TModifyScheme (парсер сложил всё, что было в
WITH
блоке в map of features и мы оттуда достаём по имени параметр за параметром)
Иначе говоря, для создания external data source через публичный API (на данных момент это исключительно YQL) нужно собрать такую вот map of features. Поэтому естественно здесь, в describe, отдавать именно её.
Дополнительное усложнение в виде выделения ExternalAuthorization кажется избыточным, потому что такой структуры нет в CREATE EXTERNAL DATA SOURCE
(она есть только на уровне приватных протобуфов SchemeShard'а), пользователь о ней не знает и в документации авторизация никак не выделена среди остальных свойств external data source
} | ||
|
||
message ExternalDataSourceProperties { | ||
map<string, string> properties = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему это упаковано в отдельное сообщение?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Когда это было на уровне ModifyScheme SS, то была идея это сделать отдельным protobuf чтобы можно было какие-то типизированные настройки добавлять. Но пока что не пригодилось)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выложил на верхний уровень DescribeExternalDataSourceResult'а и объединил с ExternalAuthorization, которые тоже развернул в map<string, string>. Подробнее в этом комменте
message None { | ||
} | ||
|
||
message Basic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас это нигде явно не зафиксировано, но мы называем такую аутентификацию "статической": https://ydb.tech/docs/ru/recipes/ydb-sdk/auth-static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Похоже мы разъехались в этом месте, тут уже упоминается как basic https://ydb.tech/docs/ru/concepts/federated_query/clickhouse :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Названия в данном месте не обязаны совпадать. Это различия между кредами к ydb и кредами к внешней системе. Статические креды-это просто некий класс кредов, можете в инете почитать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Засунул авторизацию в общее поле map<string, string> properties. Теперь уже не важно, Static или Basic. Подробнее в этом комменте
message DescribeExternalDataSourceResult { | ||
// Description of a generic scheme object. | ||
Ydb.Scheme.Entry self = 1; | ||
optional string source_type = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А какими могут быть значения этого поля? Это S3
/PostgreSQL
/MySQL
/... ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Судя по доке:
В качестве источников данных можно использовать:
Но в коде main на данный момент написано следующее (этот код относится к External Table, смотри следующий коммент):
bool ValidateSourceType(const TString& sourceType, TString& errStr) {
// Only object storage supported today
if (sourceType != "ObjectStorage") {
errStr = "Only ObjectStorage source type supported but got " + sourceType;
return false;
}
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ага, кажется, я понимаю - этот код не совсем оттуда. Этот валидатор относится к CREATE EXTERNAL TABLE
, и в этой команде действительно единственный поддерживаемый источник - это S3. А вот в CREATE EXTERNAL DATA SOURCE
поддерживаемых источников гораздо больше.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, сорри, нашёл валидацию external data source. Тут список source type побольше, но полного я не нашёл (тут разобраны только некоторые опции):
bool DataSourceMustHaveDataBaseName(const TProtoStringType& sourceType) const {
return IsIn({"Greenplum", "PostgreSQL", "MySQL", "MsSQLServer", "ClickHouse"}, sourceType);
}
⚪ Test history | Ya make output | Test bloat
⚪ Test history | Ya make output | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
lgtm |
⚪ Test history | Ya make output | Test bloat
⚪ Test history | Ya make output | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Add public API to describe external data sources and external tables.
Changelog entry
Changelog category
Additional information