diff options
author | chertus <[email protected]> | 2022-11-28 17:33:28 +0300 |
---|---|---|
committer | chertus <[email protected]> | 2022-11-28 17:33:28 +0300 |
commit | ecbd6e15e7cd4c8238013f53474f8606ffec7eae (patch) | |
tree | da8b1d79b213785891104b3e7c052ec654b8570e | |
parent | be7707450e36daf4e717fc52ecb58a870f45a705 (diff) |
ydb scheme describe --stats for ColumnTable
-rw-r--r-- | ydb/core/grpc_services/rpc_describe_table.cpp | 5 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard_info_types.h | 2 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard_path_describer.cpp | 7 | ||||
-rw-r--r-- | ydb/core/ydb_convert/table_description.cpp | 5 | ||||
-rw-r--r-- | ydb/core/ydb_convert/table_description.h | 1 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp | 17 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h | 1 |
7 files changed, 29 insertions, 9 deletions
diff --git a/ydb/core/grpc_services/rpc_describe_table.cpp b/ydb/core/grpc_services/rpc_describe_table.cpp index 16a58a86217..6f36472a232 100644 --- a/ydb/core/grpc_services/rpc_describe_table.cpp +++ b/ydb/core/grpc_services/rpc_describe_table.cpp @@ -62,7 +62,10 @@ private: FillColumnDescription(describeTableResult, tableDescription); if (GetProtoRequest()->include_table_stats()) { - FillColumnTableStats(describeTableResult, pathDescription); + FillTableStats(describeTableResult, pathDescription, false); + + describeTableResult.mutable_table_stats()->set_partitions( + tableDescription.GetColumnShardCount()); } return ReplyWithResult(Ydb::StatusIds::SUCCESS, describeTableResult, ctx); diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.h b/ydb/core/tx/schemeshard/schemeshard_info_types.h index e27b5ae4716..0b3ff48a3c9 100644 --- a/ydb/core/tx/schemeshard/schemeshard_info_types.h +++ b/ydb/core/tx/schemeshard/schemeshard_info_types.h @@ -875,6 +875,7 @@ struct TOlapStoreInfo : TSimpleRefCount<TOlapStoreInfo> { } void UpdateShardStats(TShardIdx shardIdx, const TPartitionStats& newStats) { + Stats.Aggregated.PartCount = ColumnShards.size(); Stats.PartitionStats[shardIdx]; // insert if none Stats.UpdateShardStats(shardIdx, newStats); } @@ -919,6 +920,7 @@ struct TColumnTableInfo : TSimpleRefCount<TColumnTableInfo> { } void UpdateShardStats(TShardIdx shardIdx, const TPartitionStats& newStats) { + Stats.Aggregated.PartCount = ColumnShards.size(); Stats.PartitionStats[shardIdx]; // insert if none Stats.UpdateShardStats(shardIdx, newStats); } diff --git a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp index 61fd772f19a..1a9e8e4e2f9 100644 --- a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp @@ -371,11 +371,14 @@ void TPathDescriber::DescribeColumnTable(TPathId pathId, TPathElement::TPtr path Y_VERIFY(tableInfo, "ColumnTable not found"); Y_UNUSED(pathEl); - auto description = Result->Record.MutablePathDescription()->MutableColumnTableDescription(); + auto* pathDescription = Result->Record.MutablePathDescription(); + auto description = pathDescription->MutableColumnTableDescription(); description->CopyFrom(tableInfo->Description); description->MutableSharding()->CopyFrom(tableInfo->Sharding); - if (!description->HasSchema() && description->HasSchemaPresetId()) { + if (tableInfo->IsStandalone()) { + FillAggregatedStats(*pathDescription, tableInfo->GetStats()); + } else { const TOlapStoreInfo::TPtr storeInfo = *Self->OlapStores.FindPtr(*tableInfo->OlapStorePathId); Y_VERIFY(storeInfo, "OlapStore not found"); diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index 5f81cfa2c57..c4b6dad7d05 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -500,11 +500,6 @@ void FillTableStats(Ydb::Table::DescribeTableResult& out, } } -void FillColumnTableStats(Ydb::Table::DescribeTableResult& out, const NKikimrSchemeOp::TPathDescription& in) { - auto stats = out.mutable_table_stats(); - stats->set_partitions(in.GetColumnTableDescription().GetColumnShardCount()); -} - static bool IsDefaultFamily(const NKikimrSchemeOp::TFamilyDescription& family) { if (family.HasId() && family.GetId() == 0) { return true; // explicit id 0 diff --git a/ydb/core/ydb_convert/table_description.h b/ydb/core/ydb_convert/table_description.h index 2752101bcf4..86d304f62b0 100644 --- a/ydb/core/ydb_convert/table_description.h +++ b/ydb/core/ydb_convert/table_description.h @@ -45,7 +45,6 @@ bool FillChangefeedDescription(NKikimrSchemeOp::TCdcStreamDescription& out, // out void FillTableStats(Ydb::Table::DescribeTableResult& out, const NKikimrSchemeOp::TPathDescription& in, bool withPartitionStatistic); -void FillColumnTableStats(Ydb::Table::DescribeTableResult& out, const NKikimrSchemeOp::TPathDescription& in); // out void FillStorageSettings(Ydb::Table::DescribeTableResult& out, diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp index 93c38319b21..7b7473d6698 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp @@ -158,6 +158,8 @@ int TCommandDescribe::PrintPathResponse(TDriver& driver, const NScheme::TDescrib switch (entry.Type) { case NScheme::ESchemeEntryType::Table: return DescribeTable(driver); + case NScheme::ESchemeEntryType::ColumnTable: + return DescribeColumnTable(driver); case NScheme::ESchemeEntryType::PqGroup: case NScheme::ESchemeEntryType::Topic: return DescribeTopic(driver); @@ -270,6 +272,21 @@ int TCommandDescribe::DescribeTable(TDriver& driver) { return PrintTableResponse(result); } +int TCommandDescribe::DescribeColumnTable(TDriver& driver) { + NTable::TTableClient client(driver); + NTable::TCreateSessionResult sessionResult = client.GetSession(NTable::TCreateSessionSettings()).GetValueSync(); + ThrowOnError(sessionResult); + NTable::TDescribeTableResult result = sessionResult.GetSession().DescribeTable( + Path, + FillSettings( + NTable::TDescribeTableSettings() + .WithTableStatistics(ShowTableStats) + ) + ).GetValueSync(); + ThrowOnError(result); + return PrintTableResponse(result); +} + namespace { void PrintColumns(const NTable::TTableDescription& tableDescription) { if (!tableDescription.GetTableColumns().size()) { diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h index c9765a524eb..360eaab66f2 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h @@ -43,6 +43,7 @@ public: private: int PrintPathResponse(TDriver& driver, const NScheme::TDescribePathResult& result); int DescribeTable(TDriver& driver); + int DescribeColumnTable(TDriver& driver); int PrintTableResponse(NTable::TDescribeTableResult& result); void PrintResponsePretty(const NTable::TTableDescription& tableDescription); int PrintResponseProtoJsonBase64(const NTable::TTableDescription& tableDescription); |