-
Notifications
You must be signed in to change notification settings - Fork 698
External Data Sources: RPC implementation for the describe methods + ydb scheme describe support #14509
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
Merged
jepett0
merged 4 commits into
ydb-platform:main
from
jepett0:ExternalDataSource.describe_rpc.1
Feb 13, 2025
Merged
External Data Sources: RPC implementation for the describe methods + ydb scheme describe support #14509
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
293d1e8
describe actors for external data sources and tables
jepett0 9807afd
ydb scheme describe for external data sources / external tables
jepett0 2a419a8
review fixes: no pretty format for the externals
jepett0 b872b0c
review fix: send describe request straight to the SchemeShard
jepett0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
ydb/core/grpc_services/rpc_describe_external_data_source.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include "rpc_scheme_base.h" | ||
#include "service_table.h" | ||
|
||
#include <ydb/core/grpc_services/base/base.h> | ||
#include <ydb/public/api/protos/ydb_table.pb.h> | ||
|
||
namespace NKikimr::NGRpcService { | ||
|
||
using namespace NActors; | ||
using namespace NYql; | ||
|
||
using TEvDescribeExternalDataSourceRequest = TGrpcRequestOperationCall< | ||
Ydb::Table::DescribeExternalDataSourceRequest, | ||
Ydb::Table::DescribeExternalDataSourceResponse | ||
>; | ||
|
||
class TDescribeExternalDataSourceRPC : public TRpcSchemeRequestActor<TDescribeExternalDataSourceRPC, TEvDescribeExternalDataSourceRequest> { | ||
using TBase = TRpcSchemeRequestActor<TDescribeExternalDataSourceRPC, TEvDescribeExternalDataSourceRequest>; | ||
|
||
public: | ||
|
||
using TBase::TBase; | ||
|
||
void Bootstrap() { | ||
DescribeScheme(); | ||
} | ||
|
||
private: | ||
|
||
void DescribeScheme() { | ||
auto ev = std::make_unique<TEvTxUserProxy::TEvNavigate>(); | ||
SetAuthToken(ev, *Request_); | ||
SetDatabase(ev.get(), *Request_); | ||
ev->Record.MutableDescribePath()->SetPath(GetProtoRequest()->path()); | ||
|
||
Send(MakeTxProxyID(), ev.release()); | ||
Become(&TDescribeExternalDataSourceRPC::StateDescribeScheme); | ||
} | ||
|
||
STATEFN(StateDescribeScheme) { | ||
switch (ev->GetTypeRewrite()) { | ||
HFunc(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult, Handle); | ||
default: | ||
return TBase::StateWork(ev); | ||
} | ||
} | ||
|
||
void Handle(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr& ev, const TActorContext& ctx) { | ||
const auto& record = ev->Get()->GetRecord(); | ||
const auto& pathDescription = record.GetPathDescription(); | ||
|
||
if (record.HasReason()) { | ||
Request_->RaiseIssue(TIssue(record.GetReason())); | ||
} | ||
|
||
switch (record.GetStatus()) { | ||
case NKikimrScheme::StatusSuccess: { | ||
if (pathDescription.GetSelf().GetPathType() != NKikimrSchemeOp::EPathTypeExternalDataSource) { | ||
Request_->RaiseIssue(TIssue( | ||
TStringBuilder() << "Unexpected path type: " << pathDescription.GetSelf().GetPathType() | ||
)); | ||
return Reply(Ydb::StatusIds::SCHEME_ERROR, ctx); | ||
} | ||
|
||
return ReplyWithResult( | ||
Ydb::StatusIds::SUCCESS, | ||
Ydb::Table::DescribeExternalDataSourceResult(), // to do: convert private protobuf to public | ||
ctx | ||
); | ||
} | ||
case NKikimrScheme::StatusPathDoesNotExist: | ||
case NKikimrScheme::StatusSchemeError: | ||
return Reply(Ydb::StatusIds::SCHEME_ERROR, ctx); | ||
|
||
case NKikimrScheme::StatusAccessDenied: | ||
return Reply(Ydb::StatusIds::UNAUTHORIZED, ctx); | ||
|
||
case NKikimrScheme::StatusNotAvailable: | ||
return Reply(Ydb::StatusIds::UNAVAILABLE, ctx); | ||
|
||
default: | ||
return Reply(Ydb::StatusIds::GENERIC_ERROR, ctx); | ||
} | ||
} | ||
}; | ||
|
||
void DoDescribeExternalDataSourceRequest(std::unique_ptr<IRequestOpCtx> p, const IFacilityProvider& f) { | ||
f.RegisterActor(new TDescribeExternalDataSourceRPC(p.release())); | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include "rpc_scheme_base.h" | ||
#include "service_table.h" | ||
|
||
#include <ydb/core/grpc_services/base/base.h> | ||
#include <ydb/public/api/protos/ydb_table.pb.h> | ||
|
||
namespace NKikimr::NGRpcService { | ||
|
||
using namespace NActors; | ||
using namespace NYql; | ||
|
||
using TEvDescribeExternalTableRequest = TGrpcRequestOperationCall< | ||
Ydb::Table::DescribeExternalTableRequest, | ||
Ydb::Table::DescribeExternalTableResponse | ||
>; | ||
|
||
class TDescribeExternalTableRPC : public TRpcSchemeRequestActor<TDescribeExternalTableRPC, TEvDescribeExternalTableRequest> { | ||
using TBase = TRpcSchemeRequestActor<TDescribeExternalTableRPC, TEvDescribeExternalTableRequest>; | ||
|
||
public: | ||
|
||
using TBase::TBase; | ||
|
||
void Bootstrap() { | ||
DescribeScheme(); | ||
} | ||
|
||
private: | ||
|
||
void DescribeScheme() { | ||
auto ev = std::make_unique<TEvTxUserProxy::TEvNavigate>(); | ||
SetAuthToken(ev, *Request_); | ||
SetDatabase(ev.get(), *Request_); | ||
ev->Record.MutableDescribePath()->SetPath(GetProtoRequest()->path()); | ||
|
||
Send(MakeTxProxyID(), ev.release()); | ||
Become(&TDescribeExternalTableRPC::StateDescribeScheme); | ||
} | ||
|
||
STATEFN(StateDescribeScheme) { | ||
switch (ev->GetTypeRewrite()) { | ||
HFunc(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult, Handle); | ||
default: | ||
return TBase::StateWork(ev); | ||
} | ||
} | ||
|
||
void Handle(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr& ev, const TActorContext& ctx) { | ||
const auto& record = ev->Get()->GetRecord(); | ||
const auto& pathDescription = record.GetPathDescription(); | ||
|
||
if (record.HasReason()) { | ||
Request_->RaiseIssue(TIssue(record.GetReason())); | ||
} | ||
|
||
switch (record.GetStatus()) { | ||
case NKikimrScheme::StatusSuccess: { | ||
if (pathDescription.GetSelf().GetPathType() != NKikimrSchemeOp::EPathTypeExternalTable) { | ||
Request_->RaiseIssue(TIssue( | ||
TStringBuilder() << "Unexpected path type: " << pathDescription.GetSelf().GetPathType() | ||
)); | ||
return Reply(Ydb::StatusIds::SCHEME_ERROR, ctx); | ||
} | ||
|
||
return ReplyWithResult( | ||
Ydb::StatusIds::SUCCESS, | ||
Ydb::Table::DescribeExternalTableResult(), // to do: convert private proto to public | ||
ctx | ||
); | ||
} | ||
case NKikimrScheme::StatusPathDoesNotExist: | ||
case NKikimrScheme::StatusSchemeError: | ||
return Reply(Ydb::StatusIds::SCHEME_ERROR, ctx); | ||
|
||
case NKikimrScheme::StatusAccessDenied: | ||
return Reply(Ydb::StatusIds::UNAUTHORIZED, ctx); | ||
|
||
case NKikimrScheme::StatusNotAvailable: | ||
return Reply(Ydb::StatusIds::UNAVAILABLE, ctx); | ||
|
||
default: | ||
return Reply(Ydb::StatusIds::GENERIC_ERROR, ctx); | ||
} | ||
} | ||
}; | ||
|
||
void DoDescribeExternalTableRequest(std::unique_ptr<IRequestOpCtx> p, const IFacilityProvider& f) { | ||
f.RegisterActor(new TDescribeExternalTableRPC(p.release())); | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.