Skip to content

Commit

Permalink
fix empty issue in ReadRows KIKIMR-20296
Browse files Browse the repository at this point in the history
  • Loading branch information
va-kuznecov committed Nov 30, 2023
1 parent 6239a18 commit 2e9a8ee
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 4 deletions.
1 change: 1 addition & 0 deletions ydb/core/grpc_services/CMakeLists.darwin-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ target_link_libraries(ydb-core-grpc_services PUBLIC
library-persqueue-topic_parser
parser-pg_wrapper-interface
yql-public-types
yql-public-issue
ydb-library-services
api-grpc-draft
api-protos
Expand Down
1 change: 1 addition & 0 deletions ydb/core/grpc_services/CMakeLists.darwin-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ target_link_libraries(ydb-core-grpc_services PUBLIC
library-persqueue-topic_parser
parser-pg_wrapper-interface
yql-public-types
yql-public-issue
ydb-library-services
api-grpc-draft
api-protos
Expand Down
1 change: 1 addition & 0 deletions ydb/core/grpc_services/CMakeLists.linux-aarch64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ target_link_libraries(ydb-core-grpc_services PUBLIC
library-persqueue-topic_parser
parser-pg_wrapper-interface
yql-public-types
yql-public-issue
ydb-library-services
api-grpc-draft
api-protos
Expand Down
1 change: 1 addition & 0 deletions ydb/core/grpc_services/CMakeLists.linux-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ target_link_libraries(ydb-core-grpc_services PUBLIC
library-persqueue-topic_parser
parser-pg_wrapper-interface
yql-public-types
yql-public-issue
ydb-library-services
api-grpc-draft
api-protos
Expand Down
1 change: 1 addition & 0 deletions ydb/core/grpc_services/CMakeLists.windows-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ target_link_libraries(ydb-core-grpc_services PUBLIC
library-persqueue-topic_parser
parser-pg_wrapper-interface
yql-public-types
yql-public-issue
ydb-library-services
api-grpc-draft
api-protos
Expand Down
9 changes: 5 additions & 4 deletions ydb/core/grpc_services/rpc_read_rows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,18 @@ class TReadRowsRPC : public TActorBootstrapped<TReadRowsRPC> {
void SendResult(const Ydb::StatusIds::StatusCode& status, const TString& errorMsg) {
auto* resp = CreateResponse();
resp->set_status(status);
if (!errorMsg.Empty()) {
const NYql::TIssue& issue = MakeIssue(NKikimrIssues::TIssuesIds::DEFAULT_ERROR, errorMsg);
auto* protoIssue = resp->add_issues();
NYql::IssueToMessage(issue, protoIssue);
}

if (status == Ydb::StatusIds::SUCCESS) {
Request->SetRuHeader(RuCost);

FillResultRows(resp);
}

if (errorMsg) {
Request->RaiseIssue(NYql::TIssue(errorMsg));
}

LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::RPC_REQUEST, "TReadRowsRPC sent result");
Request->Reply(resp, status);
PassAway();
Expand Down
1 change: 1 addition & 0 deletions ydb/core/grpc_services/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ PEERDIR(
ydb/library/persqueue/topic_parser
ydb/library/yql/parser/pg_wrapper/interface
ydb/library/yql/public/types
ydb/library/yql/public/issue
ydb/library/services
ydb/public/api/grpc/draft
ydb/public/api/protos
Expand Down
30 changes: 30 additions & 0 deletions ydb/core/kqp/ut/opt/kqp_kv_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ Y_UNIT_TEST_SUITE(KqpKv) {
keys.EndList();
auto selectResult = db.ReadRows("/Root/WrongTable", keys.Build()).GetValueSync();
UNIT_ASSERT_C(!selectResult.IsSuccess(), selectResult.GetIssues().ToString());
UNIT_ASSERT_C(selectResult.GetIssues().ToString().Size(), "Expect non-empty issue in case of error");
UNIT_ASSERT_EQUAL(selectResult.GetStatus(), EStatus::SCHEME_ERROR);
auto res = FormatResultSetYson(selectResult.GetResultSet());
CompareYson("[]", res);
Expand Down Expand Up @@ -279,6 +280,35 @@ Y_UNIT_TEST_SUITE(KqpKv) {
}
}

Y_UNIT_TEST(ReadRows_NotFullPK) {
auto settings = TKikimrSettings()
.SetWithSampleTables(false);
auto kikimr = TKikimrRunner{settings};
auto db = kikimr.GetTableClient();
auto session = db.CreateSession().GetValueSync().GetSession();

auto schemeResult = session.ExecuteSchemeQuery(R"(
CREATE TABLE TestTable (
Key Uint64,
Data Uint32,
Value Utf8,
PRIMARY KEY (Key)
);
)").GetValueSync();
UNIT_ASSERT_C(schemeResult.IsSuccess(), schemeResult.GetIssues().ToString());

NYdb::TValueBuilder keys;
keys.BeginList()
.AddListItem()
.BeginStruct()
.EndStruct()
.EndList();

auto selectResult = db.ReadRows("/Root/TestTable", keys.Build()).GetValueSync();
UNIT_ASSERT_C(!selectResult.IsSuccess(), selectResult.GetIssues().ToString());
UNIT_ASSERT_C(selectResult.GetIssues().ToString().Size(), "Expect non-empty issues in case of error");
}

Y_UNIT_TEST(ReadRows_SpecificReturnValue) {
auto settings = TKikimrSettings()
.SetWithSampleTables(false);
Expand Down

0 comments on commit 2e9a8ee

Please sign in to comment.