Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions ydb/core/statistics/service/service_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
entry.Operation = TNavigate::EOp::OpPath;
entry.RequestType = TNavigate::TEntry::ERequestType::ByTableId;
entry.RedirectRequired = redirectRequired;
entry.ShowPrivatePath = true;
}

void Handle(TEvStatistics::TEvGetStatistics::TPtr& ev) {
Expand Down
57 changes: 47 additions & 10 deletions ydb/core/statistics/service/ut/ut_basic_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@ using namespace NYdb::NScheme;

namespace {

void CreateTable(TTestEnv& env, const TString& databaseName, const TString& tableName, size_t rowCount) {
ExecuteYqlScript(env, Sprintf(R"(
CREATE TABLE `Root/%s/%s` (
Key Uint64,
Value Uint64,
PRIMARY KEY (Key)
);
)", databaseName.c_str(), tableName.c_str()));

void FillTable(TTestEnv& env, const TString& databaseName, const TString& tableName, size_t rowCount) {
TStringBuilder replace;
replace << Sprintf("REPLACE INTO `Root/%s/%s` (Key, Value) VALUES ",
databaseName.c_str(), tableName.c_str());
Expand All @@ -38,6 +30,29 @@ void CreateTable(TTestEnv& env, const TString& databaseName, const TString& tabl
ExecuteYqlScript(env, replace);
}

void CreateTable(TTestEnv& env, const TString& databaseName, const TString& tableName, size_t rowCount) {
ExecuteYqlScript(env, Sprintf(R"(
CREATE TABLE `Root/%s/%s` (
Key Uint64,
Value Uint64,
PRIMARY KEY (Key)
);
)", databaseName.c_str(), tableName.c_str()));
FillTable(env, databaseName, tableName, rowCount);
}

void CreateTableWithGlobalIndex(TTestEnv& env, const TString& databaseName, const TString& tableName, size_t rowCount) {
ExecuteYqlScript(env, Sprintf(R"(
CREATE TABLE `Root/%s/%s` (
Key Uint64,
Value Uint64,
INDEX ValueIndex GLOBAL ON ( Value ),
PRIMARY KEY (Key)
);
)", databaseName.c_str(), tableName.c_str()));
FillTable(env, databaseName, tableName, rowCount);
}

void ValidateRowCount(TTestActorRuntime& runtime, ui32 nodeIndex, TPathId pathId, size_t expectedRowCount) {
auto statServiceId = NStat::MakeStatServiceID(runtime.GetNodeId(nodeIndex));
ui64 rowCount = 0;
Expand Down Expand Up @@ -97,7 +112,6 @@ ui64 GetRowCount(TTestActorRuntime& runtime, ui32 nodeIndex, TPathId pathId) {
} // namespace

Y_UNIT_TEST_SUITE(BasicStatistics) {

Y_UNIT_TEST(Simple) {
TTestEnv env(1, 1);

Expand Down Expand Up @@ -254,6 +268,29 @@ Y_UNIT_TEST_SUITE(BasicStatistics) {

TestNotFullStatistics(env, 1000);
}

Y_UNIT_TEST(SimpleGlobalIndex) {
TTestEnv env(1, 1);

CreateDatabase(env, "Database");
CreateTableWithGlobalIndex(env, "Database", "Table", 5);

auto& runtime = *env.GetServer().GetRuntime();
auto pathId = ResolvePathId(runtime, "/Root/Database/Table/ValueIndex/indexImplTable");
ValidateRowCount(runtime, 1, pathId, 5);
}

Y_UNIT_TEST(ServerlessGlobalIndex) {
TTestEnv env(1, 1);

CreateDatabase(env, "Shared", 1, true);
CreateServerlessDatabase(env, "Serverless", "/Root/Shared");
CreateTableWithGlobalIndex(env, "Serverless", "Table", 5);

auto& runtime = *env.GetServer().GetRuntime();
auto pathId = ResolvePathId(runtime, "/Root/Serverless/Table/ValueIndex/indexImplTable");
ValidateRowCount(runtime, 1, pathId, 5);
}
}

} // NSysView
Expand Down
Loading