@@ -72,6 +72,78 @@ static void FillTableStats(NKikimrSchemeOp::TPathDescription& pathDescription, c
7272 FillTableMetrics (pathDescription.MutableTabletMetrics (), stats);
7373}
7474
75+ static void FillColumns (
76+ const TTableInfo& tableInfo,
77+ google::protobuf::RepeatedPtrField<NKikimrSchemeOp::TColumnDescription>& out
78+ ) {
79+ bool familyNamesBuilt = false ;
80+ THashMap<ui32, TString> familyNames;
81+
82+ out.Reserve (tableInfo.Columns .size ());
83+ for (const auto & col : tableInfo.Columns ) {
84+ const auto & cinfo = col.second ;
85+ if (cinfo.IsDropped ())
86+ continue ;
87+
88+ auto * colDescr = out.Add ();
89+ colDescr->SetName (cinfo.Name );
90+ colDescr->SetType (NScheme::TypeName (cinfo.PType , cinfo.PTypeMod ));
91+ auto columnType = NScheme::ProtoColumnTypeFromTypeInfoMod (cinfo.PType , cinfo.PTypeMod );
92+ colDescr->SetTypeId (columnType.TypeId );
93+ if (columnType.TypeInfo ) {
94+ *colDescr->MutableTypeInfo () = *columnType.TypeInfo ;
95+ }
96+ colDescr->SetId (cinfo.Id );
97+ colDescr->SetNotNull (cinfo.NotNull );
98+
99+ if (cinfo.Family != 0 ) {
100+ colDescr->SetFamily (cinfo.Family );
101+
102+ if (!familyNamesBuilt) {
103+ for (const auto & family : tableInfo.PartitionConfig ().GetColumnFamilies ()) {
104+ if (family.HasName () && family.HasId ()) {
105+ familyNames[family.GetId ()] = family.GetName ();
106+ }
107+ }
108+ familyNamesBuilt = true ;
109+ }
110+
111+ auto it = familyNames.find (cinfo.Family );
112+ if (it != familyNames.end () && !it->second .empty ()) {
113+ colDescr->SetFamilyName (it->second );
114+ }
115+ }
116+
117+ colDescr->SetIsBuildInProgress (cinfo.IsBuildInProgress );
118+
119+ switch (cinfo.DefaultKind ) {
120+ case ETableColumnDefaultKind::None:
121+ break ;
122+ case ETableColumnDefaultKind::FromSequence:
123+ colDescr->SetDefaultFromSequence (cinfo.DefaultValue );
124+ break ;
125+ case ETableColumnDefaultKind::FromLiteral:
126+ Y_ABORT_UNLESS (colDescr->MutableDefaultFromLiteral ()->ParseFromString (
127+ cinfo.DefaultValue ));
128+ break ;
129+ }
130+ }
131+ }
132+
133+ static void FillKeyColumns (
134+ const TTableInfo& tableInfo,
135+ google::protobuf::RepeatedPtrField<TProtoStringType>& names,
136+ google::protobuf::RepeatedField<ui32>& ids
137+ ) {
138+ Y_ABORT_UNLESS (!tableInfo.KeyColumnIds .empty ());
139+ names.Reserve (tableInfo.KeyColumnIds .size ());
140+ ids.Reserve (tableInfo.KeyColumnIds .size ());
141+ for (ui32 keyColId : tableInfo.KeyColumnIds ) {
142+ *names.Add () = tableInfo.Columns .at (keyColId).Name ;
143+ *ids.Add () = keyColId;
144+ }
145+ }
146+
75147void TPathDescriber::FillPathDescr (NKikimrSchemeOp::TDirEntry* descr, TPathElement::TPtr pathEl, TPathElement::EPathSubType subType) {
76148 FillChildDescr (descr, pathEl);
77149
@@ -292,6 +364,7 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
292364 bool returnBoundaries = false ;
293365 bool returnRangeKey = true ;
294366 bool returnSetVal = Params.GetOptions ().GetReturnSetVal ();
367+ bool returnIndexTableBoundaries = Params.GetOptions ().GetReturnIndexTableBoundaries ();
295368 if (Params.HasOptions ()) {
296369 returnConfig = Params.GetOptions ().GetReturnPartitionConfig ();
297370 returnPartitioning = Params.GetOptions ().GetReturnPartitioningInfo ();
@@ -416,7 +489,9 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
416489
417490 switch (childPath->PathType ) {
418491 case NKikimrSchemeOp::EPathTypeTableIndex:
419- Self->DescribeTableIndex (childPathId, childName, returnConfig, false , *entry->AddTableIndexes ());
492+ Self->DescribeTableIndex (
493+ childPathId, childName, returnConfig, returnIndexTableBoundaries, *entry->AddTableIndexes ()
494+ );
420495 break ;
421496 case NKikimrSchemeOp::EPathTypeCdcStream:
422497 Self->DescribeCdcStream (childPathId, childName, *entry->AddCdcStreams ());
@@ -1174,67 +1249,10 @@ void TSchemeShard::DescribeTable(
11741249 ) const
11751250{
11761251 Y_UNUSED (typeRegistry);
1177- THashMap<ui32, TString> familyNames;
1178- bool familyNamesBuilt = false ;
11791252
11801253 entry->SetTableSchemaVersion (tableInfo->AlterVersion );
1181- entry->MutableColumns ()->Reserve (tableInfo->Columns .size ());
1182- for (auto col : tableInfo->Columns ) {
1183- const auto & cinfo = col.second ;
1184- if (cinfo.IsDropped ())
1185- continue ;
1186-
1187- auto colDescr = entry->AddColumns ();
1188- colDescr->SetName (cinfo.Name );
1189- colDescr->SetType (NScheme::TypeName (cinfo.PType , cinfo.PTypeMod ));
1190- auto columnType = NScheme::ProtoColumnTypeFromTypeInfoMod (cinfo.PType , cinfo.PTypeMod );
1191- colDescr->SetTypeId (columnType.TypeId );
1192- if (columnType.TypeInfo ) {
1193- *colDescr->MutableTypeInfo () = *columnType.TypeInfo ;
1194- }
1195- colDescr->SetId (cinfo.Id );
1196- colDescr->SetNotNull (cinfo.NotNull );
1197-
1198- if (cinfo.Family != 0 ) {
1199- colDescr->SetFamily (cinfo.Family );
1200-
1201- if (!familyNamesBuilt) {
1202- for (const auto & family : tableInfo->PartitionConfig ().GetColumnFamilies ()) {
1203- if (family.HasName () && family.HasId ()) {
1204- familyNames[family.GetId ()] = family.GetName ();
1205- }
1206- }
1207- familyNamesBuilt = true ;
1208- }
1209-
1210- auto it = familyNames.find (cinfo.Family );
1211- if (it != familyNames.end () && !it->second .empty ()) {
1212- colDescr->SetFamilyName (it->second );
1213- }
1214- }
1215-
1216- colDescr->SetIsBuildInProgress (cinfo.IsBuildInProgress );
1217-
1218- switch (cinfo.DefaultKind ) {
1219- case ETableColumnDefaultKind::None:
1220- break ;
1221- case ETableColumnDefaultKind::FromSequence:
1222- colDescr->SetDefaultFromSequence (cinfo.DefaultValue );
1223- break ;
1224- case ETableColumnDefaultKind::FromLiteral:
1225- Y_ABORT_UNLESS (colDescr->MutableDefaultFromLiteral ()->ParseFromString (
1226- cinfo.DefaultValue ));
1227- break ;
1228- }
1229- }
1230- Y_ABORT_UNLESS (!tableInfo->KeyColumnIds .empty ());
1231-
1232- entry->MutableKeyColumnNames ()->Reserve (tableInfo->KeyColumnIds .size ());
1233- entry->MutableKeyColumnIds ()->Reserve (tableInfo->KeyColumnIds .size ());
1234- for (ui32 keyColId : tableInfo->KeyColumnIds ) {
1235- entry->AddKeyColumnNames (tableInfo->Columns [keyColId].Name );
1236- entry->AddKeyColumnIds (keyColId);
1237- }
1254+ FillColumns (*tableInfo, *entry->MutableColumns ());
1255+ FillKeyColumns (*tableInfo, *entry->MutableKeyColumnNames (), *entry->MutableKeyColumnIds ());
12381256
12391257 if (fillConfig) {
12401258 FillPartitionConfig (tableInfo->PartitionConfig (), *entry->MutablePartitionConfig ());
@@ -1298,6 +1316,9 @@ void TSchemeShard::DescribeTableIndex(const TPathId& pathId, const TString& name
12981316 FillPartitionConfig (tableInfo->PartitionConfig (), *tableDescription->MutablePartitionConfig ());
12991317 }
13001318 if (fillBoundaries) {
1319+ // column info is necessary for split boundary type conversion
1320+ FillColumns (*tableInfo, *tableDescription->MutableColumns ());
1321+ FillKeyColumns (*tableInfo, *tableDescription->MutableKeyColumnNames (), *tableDescription->MutableKeyColumnIds ());
13011322 FillTableBoundaries (tableDescription->MutableSplitBoundary (), tableInfo);
13021323 }
13031324}
0 commit comments