@@ -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 ());
@@ -1172,67 +1247,10 @@ void TSchemeShard::DescribeTable(
11721247 ) const
11731248{
11741249 Y_UNUSED (typeRegistry);
1175- THashMap<ui32, TString> familyNames;
1176- bool familyNamesBuilt = false ;
11771250
11781251 entry->SetTableSchemaVersion (tableInfo->AlterVersion );
1179- entry->MutableColumns ()->Reserve (tableInfo->Columns .size ());
1180- for (auto col : tableInfo->Columns ) {
1181- const auto & cinfo = col.second ;
1182- if (cinfo.IsDropped ())
1183- continue ;
1184-
1185- auto colDescr = entry->AddColumns ();
1186- colDescr->SetName (cinfo.Name );
1187- colDescr->SetType (NScheme::TypeName (cinfo.PType , cinfo.PTypeMod ));
1188- auto columnType = NScheme::ProtoColumnTypeFromTypeInfoMod (cinfo.PType , cinfo.PTypeMod );
1189- colDescr->SetTypeId (columnType.TypeId );
1190- if (columnType.TypeInfo ) {
1191- *colDescr->MutableTypeInfo () = *columnType.TypeInfo ;
1192- }
1193- colDescr->SetId (cinfo.Id );
1194- colDescr->SetNotNull (cinfo.NotNull );
1195-
1196- if (cinfo.Family != 0 ) {
1197- colDescr->SetFamily (cinfo.Family );
1198-
1199- if (!familyNamesBuilt) {
1200- for (const auto & family : tableInfo->PartitionConfig ().GetColumnFamilies ()) {
1201- if (family.HasName () && family.HasId ()) {
1202- familyNames[family.GetId ()] = family.GetName ();
1203- }
1204- }
1205- familyNamesBuilt = true ;
1206- }
1207-
1208- auto it = familyNames.find (cinfo.Family );
1209- if (it != familyNames.end () && !it->second .empty ()) {
1210- colDescr->SetFamilyName (it->second );
1211- }
1212- }
1213-
1214- colDescr->SetIsBuildInProgress (cinfo.IsBuildInProgress );
1215-
1216- switch (cinfo.DefaultKind ) {
1217- case ETableColumnDefaultKind::None:
1218- break ;
1219- case ETableColumnDefaultKind::FromSequence:
1220- colDescr->SetDefaultFromSequence (cinfo.DefaultValue );
1221- break ;
1222- case ETableColumnDefaultKind::FromLiteral:
1223- Y_ABORT_UNLESS (colDescr->MutableDefaultFromLiteral ()->ParseFromString (
1224- cinfo.DefaultValue ));
1225- break ;
1226- }
1227- }
1228- Y_ABORT_UNLESS (!tableInfo->KeyColumnIds .empty ());
1229-
1230- entry->MutableKeyColumnNames ()->Reserve (tableInfo->KeyColumnIds .size ());
1231- entry->MutableKeyColumnIds ()->Reserve (tableInfo->KeyColumnIds .size ());
1232- for (ui32 keyColId : tableInfo->KeyColumnIds ) {
1233- entry->AddKeyColumnNames (tableInfo->Columns [keyColId].Name );
1234- entry->AddKeyColumnIds (keyColId);
1235- }
1252+ FillColumns (*tableInfo, *entry->MutableColumns ());
1253+ FillKeyColumns (*tableInfo, *entry->MutableKeyColumnNames (), *entry->MutableKeyColumnIds ());
12361254
12371255 if (fillConfig) {
12381256 FillPartitionConfig (tableInfo->PartitionConfig (), *entry->MutablePartitionConfig ());
@@ -1296,6 +1314,9 @@ void TSchemeShard::DescribeTableIndex(const TPathId& pathId, const TString& name
12961314 FillPartitionConfig (tableInfo->PartitionConfig (), *tableDescription->MutablePartitionConfig ());
12971315 }
12981316 if (fillBoundaries) {
1317+ // column info is necessary for split boundary type conversion
1318+ FillColumns (*tableInfo, *tableDescription->MutableColumns ());
1319+ FillKeyColumns (*tableInfo, *tableDescription->MutableKeyColumnNames (), *tableDescription->MutableKeyColumnIds ());
12991320 FillTableBoundaries (tableDescription->MutableSplitBoundary (), tableInfo);
13001321 }
13011322}
0 commit comments