Skip to content

Commit 7b41518

Browse files
shmel1kasmyasnikov
authored andcommitted
[table] fix missing index type for table description
1 parent 6c8b38d commit 7b41518

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

internal/table/session.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,19 @@ func (s *session) DescribeTable(
410410

411411
indexes := make([]options.IndexDescription, len(result.Indexes))
412412
for i, idx := range result.GetIndexes() {
413+
var typ options.IndexType
414+
switch idx.Type.(type) {
415+
case *Ydb_Table.TableIndexDescription_GlobalAsyncIndex:
416+
typ = options.GlobalAsyncIndex()
417+
case *Ydb_Table.TableIndexDescription_GlobalIndex:
418+
typ = options.GlobalIndex()
419+
}
413420
indexes[i] = options.IndexDescription{
414421
Name: idx.GetName(),
415422
IndexColumns: idx.GetIndexColumns(),
416423
DataColumns: idx.GetDataColumns(),
417424
Status: idx.GetStatus(),
425+
Type: typ,
418426
}
419427
}
420428

table/options/models.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,22 @@ type IndexDescription struct {
4040
IndexColumns []string
4141
DataColumns []string
4242
Status Ydb_Table.TableIndexDescription_Status
43+
Type IndexType
4344
}
4445

4546
//nolint:unused
4647
func (i IndexDescription) toYDB() *Ydb_Table.TableIndexDescription {
47-
return &Ydb_Table.TableIndexDescription{
48+
res := &Ydb_Table.TableIndexDescription{
4849
Name: i.Name,
4950
IndexColumns: i.IndexColumns,
5051
Status: i.Status,
5152
}
53+
if i.Type.Type() == IndexTypeGlobal {
54+
res.Type = &Ydb_Table.TableIndexDescription_GlobalIndex{}
55+
} else {
56+
res.Type = &Ydb_Table.TableIndexDescription_GlobalAsyncIndex{}
57+
}
58+
return res
5259
}
5360

5461
type Description struct {
@@ -270,8 +277,16 @@ func NewPartitioningSettings(ps *Ydb_Table.PartitioningSettings) PartitioningSet
270277
}
271278
}
272279

280+
type IndexTypeValue uint8
281+
282+
const (
283+
IndexTypeGlobal IndexTypeValue = iota
284+
IndexTypeGlobalAsync
285+
)
286+
273287
type IndexType interface {
274288
setup(*indexDesc)
289+
Type() IndexTypeValue
275290
}
276291

277292
type globalIndex struct{}
@@ -286,6 +301,10 @@ func (globalIndex) setup(d *indexDesc) {
286301
}
287302
}
288303

304+
func (globalIndex) Type() IndexTypeValue {
305+
return IndexTypeGlobal
306+
}
307+
289308
type globalAsyncIndex struct{}
290309

291310
func GlobalAsyncIndex() IndexType {
@@ -298,6 +317,10 @@ func (globalAsyncIndex) setup(d *indexDesc) {
298317
}
299318
}
300319

320+
func (globalAsyncIndex) Type() IndexTypeValue {
321+
return IndexTypeGlobalAsync
322+
}
323+
301324
type PartitioningMode byte
302325

303326
const (

0 commit comments

Comments
 (0)