@@ -73,6 +73,79 @@ static void FillTableStats(NKikimrSchemeOp::TPathDescription& pathDescription, c
7373 FillTableMetrics (pathDescription.MutableTabletMetrics (), stats);
7474}
7575
76+ static void FillColumns (
77+ const TTableInfo& tableInfo,
78+ google::protobuf::RepeatedPtrField<NKikimrSchemeOp::TColumnDescription>& out
79+ ) {
80+ bool familyNamesBuilt = false ;
81+ THashMap<ui32, TString> familyNames;
82+
83+ out.Reserve (tableInfo.Columns .size ());
84+ for (const auto & col : tableInfo.Columns ) {
85+ const auto & cinfo = col.second ;
86+ if (cinfo.IsDropped ())
87+ continue ;
88+
89+ auto * colDescr = out.Add ();
90+ colDescr->SetName (cinfo.Name );
91+ colDescr->SetType (NScheme::TypeName (cinfo.PType , cinfo.PTypeMod ));
92+ auto columnType = NScheme::ProtoColumnTypeFromTypeInfoMod (cinfo.PType , cinfo.PTypeMod );
93+ colDescr->SetTypeId (columnType.TypeId );
94+ if (columnType.TypeInfo ) {
95+ *colDescr->MutableTypeInfo () = *columnType.TypeInfo ;
96+ }
97+ colDescr->SetId (cinfo.Id );
98+ colDescr->SetNotNull (cinfo.NotNull );
99+
100+ if (cinfo.Family != 0 ) {
101+ colDescr->SetFamily (cinfo.Family );
102+
103+ if (!familyNamesBuilt) {
104+ for (const auto & family : tableInfo.PartitionConfig ().GetColumnFamilies ()) {
105+ if (family.HasName () && family.HasId ()) {
106+ familyNames[family.GetId ()] = family.GetName ();
107+ }
108+ }
109+ familyNamesBuilt = true ;
110+ }
111+
112+ auto it = familyNames.find (cinfo.Family );
113+ if (it != familyNames.end () && !it->second .empty ()) {
114+ colDescr->SetFamilyName (it->second );
115+ }
116+ }
117+
118+ colDescr->SetIsBuildInProgress (cinfo.IsBuildInProgress );
119+
120+ switch (cinfo.DefaultKind ) {
121+ case ETableColumnDefaultKind::None:
122+ break ;
123+ case ETableColumnDefaultKind::FromSequence:
124+ colDescr->SetDefaultFromSequence (cinfo.DefaultValue );
125+ break ;
126+ case ETableColumnDefaultKind::FromLiteral:
127+ Y_ABORT_UNLESS (colDescr->MutableDefaultFromLiteral ()->ParseFromString (
128+ cinfo.DefaultValue ));
129+ break ;
130+ }
131+ }
132+ }
133+
134+ static void FillKeyColumns (
135+ const TTableInfo& tableInfo,
136+ google::protobuf::RepeatedPtrField<TProtoStringType>& names,
137+ google::protobuf::RepeatedField<ui32>& ids
138+ ) {
139+ Y_ABORT_UNLESS (!tableInfo.KeyColumnIds .empty ());
140+ names.Reserve (tableInfo.KeyColumnIds .size ());
141+ ids.Reserve (tableInfo.KeyColumnIds .size ());
142+ for (ui32 keyColId : tableInfo.KeyColumnIds ) {
143+ *names.Add () = tableInfo.Columns .at (keyColId).Name ;
144+ *ids.Add () = keyColId;
145+ }
146+
147+ }
148+
76149void TPathDescriber::FillPathDescr (NKikimrSchemeOp::TDirEntry* descr, TPathElement::TPtr pathEl, TPathElement::EPathSubType subType) {
77150 FillChildDescr (descr, pathEl);
78151
@@ -303,6 +376,7 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
303376 bool returnBoundaries = false ;
304377 bool returnRangeKey = true ;
305378 bool returnSetVal = Params.GetOptions ().GetReturnSetVal ();
379+ bool returnIndexTableBoundaries = Params.GetOptions ().GetReturnIndexTableBoundaries ();
306380 if (Params.HasOptions ()) {
307381 returnConfig = Params.GetOptions ().GetReturnPartitionConfig ();
308382 returnPartitioning = Params.GetOptions ().GetReturnPartitioningInfo ();
@@ -427,7 +501,9 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
427501
428502 switch (childPath->PathType ) {
429503 case NKikimrSchemeOp::EPathTypeTableIndex:
430- Self->DescribeTableIndex (childPathId, childName, returnConfig, false , *entry->AddTableIndexes ());
504+ Self->DescribeTableIndex (
505+ childPathId, childName, returnConfig, returnIndexTableBoundaries, *entry->AddTableIndexes ()
506+ );
431507 break ;
432508 case NKikimrSchemeOp::EPathTypeCdcStream:
433509 Self->DescribeCdcStream (childPathId, childName, *entry->AddCdcStreams ());
@@ -1189,67 +1265,10 @@ void TSchemeShard::DescribeTable(
11891265 ) const
11901266{
11911267 Y_UNUSED (typeRegistry);
1192- THashMap<ui32, TString> familyNames;
1193- bool familyNamesBuilt = false ;
11941268
11951269 entry->SetTableSchemaVersion (tableInfo.AlterVersion );
1196- entry->MutableColumns ()->Reserve (tableInfo.Columns .size ());
1197- for (auto col : tableInfo.Columns ) {
1198- const auto & cinfo = col.second ;
1199- if (cinfo.IsDropped ())
1200- continue ;
1201-
1202- auto colDescr = entry->AddColumns ();
1203- colDescr->SetName (cinfo.Name );
1204- colDescr->SetType (NScheme::TypeName (cinfo.PType , cinfo.PTypeMod ));
1205- auto columnType = NScheme::ProtoColumnTypeFromTypeInfoMod (cinfo.PType , cinfo.PTypeMod );
1206- colDescr->SetTypeId (columnType.TypeId );
1207- if (columnType.TypeInfo ) {
1208- *colDescr->MutableTypeInfo () = *columnType.TypeInfo ;
1209- }
1210- colDescr->SetId (cinfo.Id );
1211- colDescr->SetNotNull (cinfo.NotNull );
1212-
1213- if (cinfo.Family != 0 ) {
1214- colDescr->SetFamily (cinfo.Family );
1215-
1216- if (!familyNamesBuilt) {
1217- for (const auto & family : tableInfo.PartitionConfig ().GetColumnFamilies ()) {
1218- if (family.HasName () && family.HasId ()) {
1219- familyNames[family.GetId ()] = family.GetName ();
1220- }
1221- }
1222- familyNamesBuilt = true ;
1223- }
1224-
1225- auto it = familyNames.find (cinfo.Family );
1226- if (it != familyNames.end () && !it->second .empty ()) {
1227- colDescr->SetFamilyName (it->second );
1228- }
1229- }
1230-
1231- colDescr->SetIsBuildInProgress (cinfo.IsBuildInProgress );
1232-
1233- switch (cinfo.DefaultKind ) {
1234- case ETableColumnDefaultKind::None:
1235- break ;
1236- case ETableColumnDefaultKind::FromSequence:
1237- colDescr->SetDefaultFromSequence (cinfo.DefaultValue );
1238- break ;
1239- case ETableColumnDefaultKind::FromLiteral:
1240- Y_ABORT_UNLESS (colDescr->MutableDefaultFromLiteral ()->ParseFromString (
1241- cinfo.DefaultValue ));
1242- break ;
1243- }
1244- }
1245- Y_ABORT_UNLESS (!tableInfo.KeyColumnIds .empty ());
1246-
1247- entry->MutableKeyColumnNames ()->Reserve (tableInfo.KeyColumnIds .size ());
1248- entry->MutableKeyColumnIds ()->Reserve (tableInfo.KeyColumnIds .size ());
1249- for (ui32 keyColId : tableInfo.KeyColumnIds ) {
1250- entry->AddKeyColumnNames (tableInfo.Columns .at (keyColId).Name );
1251- entry->AddKeyColumnIds (keyColId);
1252- }
1270+ FillColumns (tableInfo, *entry->MutableColumns ());
1271+ FillKeyColumns (tableInfo, *entry->MutableKeyColumnNames (), *entry->MutableKeyColumnIds ());
12531272
12541273 if (fillConfig) {
12551274 FillPartitionConfig (tableInfo.PartitionConfig (), *entry->MutablePartitionConfig ());
@@ -1328,6 +1347,9 @@ void TSchemeShard::DescribeTableIndex(const TPathId& pathId, const TString& name
13281347 FillPartitionConfig (tableInfo.PartitionConfig (), *tableDescription->MutablePartitionConfig ());
13291348 }
13301349 if (fillBoundaries) {
1350+ // column info is necessary for split boundary type conversion
1351+ FillColumns (tableInfo, *tableDescription->MutableColumns ());
1352+ FillKeyColumns (tableInfo, *tableDescription->MutableKeyColumnNames (), *tableDescription->MutableKeyColumnIds ());
13311353 FillTableBoundaries (tableDescription->MutableSplitBoundary (), tableInfo);
13321354 }
13331355 }
0 commit comments