mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-18 19:41:11 -05:00
adding index prefix lengths in creation instead of setting
This commit is contained in:
@@ -64,9 +64,9 @@ func createTestSchema(t *testing.T) schema.Schema {
|
||||
)
|
||||
sch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexName, []uint64{firstTag, lastTag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexName, []uint64{firstTag, lastTag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexAge, []uint64{ageTag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexAge, []uint64{ageTag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
return sch
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func Schema() (schema.Schema, error) {
|
||||
)
|
||||
sch := schema.MustSchemaFromCols(typedColColl)
|
||||
|
||||
_, err := sch.Indexes().AddIndexByColTags(IndexName, []uint64{NameTag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
_, err := sch.Indexes().AddIndexByColTags(IndexName, []uint64{NameTag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ var indexSchema schema.Index
|
||||
var compositeIndexSchema schema.Index
|
||||
|
||||
func init() {
|
||||
indexSchema, _ = sch.Indexes().AddIndexByColTags("idx_col1", []uint64{col1Tag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
compositeIndexSchema, _ = sch.Indexes().AddIndexByColTags("idx_col1_col2", []uint64{col1Tag, col2Tag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
indexSchema, _ = sch.Indexes().AddIndexByColTags("idx_col1", []uint64{col1Tag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
compositeIndexSchema, _ = sch.Indexes().AddIndexByColTags("idx_col1_col2", []uint64{col1Tag, col2Tag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
}
|
||||
|
||||
type rowV struct {
|
||||
|
||||
@@ -154,7 +154,7 @@ func SetupHookRefKeys(ctx context.Context, dEnv *env.DoltEnv) (*env.DoltEnv, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = sch.Indexes().AddIndexByColNames("blob_idx", []string{"c1"}, schema.IndexProperties{IsUserDefined: true})
|
||||
_, err = sch.Indexes().AddIndexByColNames("blob_idx", []string{"c1"}, nil, schema.IndexProperties{IsUserDefined: true})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ var sch, _ = schema.SchemaFromPKAndNonPKCols(testKeyColColl, testNonKeyColColl)
|
||||
var index schema.Index
|
||||
|
||||
func init() {
|
||||
index, _ = sch.Indexes().AddIndexByColTags(indexName, []uint64{ageColTag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
index, _ = sch.Indexes().AddIndexByColTags(indexName, []uint64{ageColTag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
}
|
||||
|
||||
func newTestRow() (Row, error) {
|
||||
|
||||
@@ -243,7 +243,7 @@ func toSchemaData(sch schema.Schema) (schemaData, error) {
|
||||
Comment: index.Comment(),
|
||||
Unique: index.IsUnique(),
|
||||
IsSystemDefined: !index.IsUserDefined(),
|
||||
PrefixLengths: index.GetPrefixLengths(),
|
||||
PrefixLengths: index.PrefixLengths(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +302,7 @@ func (sd schemaData) addChecksIndexesAndPkOrderingToSchema(sch schema.Schema) er
|
||||
_, err := sch.Indexes().UnsafeAddIndexByColTags(
|
||||
encodedIndex.Name,
|
||||
encodedIndex.Tags,
|
||||
encodedIndex.PrefixLengths,
|
||||
schema.IndexProperties{
|
||||
IsUnique: encodedIndex.Unique,
|
||||
IsUserDefined: !encodedIndex.IsSystemDefined,
|
||||
@@ -311,10 +312,6 @@ func (sd schemaData) addChecksIndexesAndPkOrderingToSchema(sch schema.Schema) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = sch.Indexes().SetIndexPrefixLength(encodedIndex.Name, encodedIndex.PrefixLengths)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, encodedCheck := range sd.CheckConstraints {
|
||||
|
||||
@@ -46,7 +46,7 @@ func createTestSchema() schema.Schema {
|
||||
|
||||
colColl := schema.NewColCollection(columns...)
|
||||
sch := schema.MustSchemaFromCols(colColl)
|
||||
_, _ = sch.Indexes().AddIndexByColTags("idx_age", []uint64{3}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
_, _ = sch.Indexes().AddIndexByColTags("idx_age", []uint64{3}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
return sch
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func (tsd testSchemaData) decodeSchema() (schema.Schema, error) {
|
||||
sch.SetCollation(tsd.Collation)
|
||||
|
||||
for _, encodedIndex := range tsd.IndexCollection {
|
||||
_, err = sch.Indexes().AddIndexByColTags(encodedIndex.Name, encodedIndex.Tags, schema.IndexProperties{IsUnique: encodedIndex.Unique, Comment: encodedIndex.Comment})
|
||||
_, err = sch.Indexes().AddIndexByColTags(encodedIndex.Name, encodedIndex.Tags, nil, schema.IndexProperties{IsUnique: encodedIndex.Unique, Comment: encodedIndex.Comment})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ func serializeSecondaryIndexes(b *fb.Builder, sch schema.Schema, indexes []schem
|
||||
ko := b.EndVector(len(tags))
|
||||
|
||||
// serialize prefix lengths
|
||||
prefixLengths := idx.GetPrefixLengths()
|
||||
prefixLengths := idx.PrefixLengths()
|
||||
serial.IndexStartPrefixLengthsVector(b, len(prefixLengths))
|
||||
for j := len(prefixLengths) - 1; j >= 0; j-- {
|
||||
b.PrependUint16(prefixLengths[j])
|
||||
@@ -381,17 +381,15 @@ func deserializeSecondaryIndexes(sch schema.Schema, s *serial.TableSchema) error
|
||||
tags[j] = col.Tag()
|
||||
}
|
||||
|
||||
_, err := sch.Indexes().AddIndexByColTags(name, tags, props)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prefixLengths := make([]uint16, idx.PrefixLengthsLength())
|
||||
for j := range prefixLengths {
|
||||
prefixLengths[j] = idx.PrefixLengths(j)
|
||||
}
|
||||
schIdx := sch.Indexes().GetByName(name)
|
||||
schIdx.SetPrefixLengths(prefixLengths)
|
||||
|
||||
_, err := sch.Indexes().AddIndexByColTags(name, tags, prefixLengths, props)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -54,10 +54,8 @@ type Index interface {
|
||||
// ToTableTuple returns a tuple that may be used to retrieve the original row from the indexed table when given
|
||||
// a full index key (and not a partial index key).
|
||||
ToTableTuple(ctx context.Context, fullKey types.Tuple, format *types.NomsBinFormat) (types.Tuple, error)
|
||||
// GetPrefixLengths returns the prefix lengths for the index
|
||||
GetPrefixLengths() []uint16
|
||||
// SetPrefixLengths applies to prefix lengths
|
||||
SetPrefixLengths(prefixLengths []uint16)
|
||||
// PrefixLengths returns the prefix lengths for the index
|
||||
PrefixLengths() []uint16
|
||||
}
|
||||
|
||||
var _ Index = (*indexImpl)(nil)
|
||||
@@ -247,15 +245,10 @@ func (ix *indexImpl) ToTableTuple(ctx context.Context, fullKey types.Tuple, form
|
||||
}
|
||||
|
||||
// GetPrefixLengths implements Index.
|
||||
func (ix *indexImpl) GetPrefixLengths() []uint16 {
|
||||
func (ix *indexImpl) PrefixLengths() []uint16 {
|
||||
return ix.prefixLengths
|
||||
}
|
||||
|
||||
// SetPrefixLengths implements Index.
|
||||
func (ix *indexImpl) SetPrefixLengths(prefixLengths []uint16) {
|
||||
ix.prefixLengths = prefixLengths
|
||||
}
|
||||
|
||||
// copy returns an exact copy of the calling index.
|
||||
func (ix *indexImpl) copy() *indexImpl {
|
||||
newIx := *ix
|
||||
|
||||
@@ -25,11 +25,11 @@ type IndexCollection interface {
|
||||
// It does not perform any kind of checking, and is intended for schema modifications.
|
||||
AddIndex(indexes ...Index)
|
||||
// AddIndexByColNames adds an index with the given name and columns (in index order).
|
||||
AddIndexByColNames(indexName string, cols []string, props IndexProperties) (Index, error)
|
||||
AddIndexByColNames(indexName string, cols []string, prefixLengths []uint16, props IndexProperties) (Index, error)
|
||||
// AddIndexByColTags adds an index with the given name and column tags (in index order).
|
||||
AddIndexByColTags(indexName string, tags []uint64, props IndexProperties) (Index, error)
|
||||
AddIndexByColTags(indexName string, tags []uint64, prefixLengths []uint16, props IndexProperties) (Index, error)
|
||||
// todo: this method is trash, clean up this interface
|
||||
UnsafeAddIndexByColTags(indexName string, tags []uint64, props IndexProperties) (Index, error)
|
||||
UnsafeAddIndexByColTags(indexName string, tags []uint64, prefixLengths []uint16, props IndexProperties) (Index, error)
|
||||
// AllIndexes returns a slice containing all of the indexes in this collection.
|
||||
AllIndexes() []Index
|
||||
// Contains returns whether the given index name already exists for this table.
|
||||
@@ -64,8 +64,6 @@ type IndexCollection interface {
|
||||
RenameIndex(oldName, newName string) (Index, error)
|
||||
//SetPks changes the pks or pk ordinals
|
||||
SetPks([]uint64) error
|
||||
// SetIndexPrefixLength sets the prefix lengths for the specified index
|
||||
SetIndexPrefixLength(indexName string, prefixLengths []uint16) error
|
||||
}
|
||||
|
||||
type IndexProperties struct {
|
||||
@@ -127,15 +125,15 @@ func (ixc *indexCollectionImpl) AddIndex(indexes ...Index) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ixc *indexCollectionImpl) AddIndexByColNames(indexName string, cols []string, props IndexProperties) (Index, error) {
|
||||
func (ixc *indexCollectionImpl) AddIndexByColNames(indexName string, cols []string, prefixLengths []uint16, props IndexProperties) (Index, error) {
|
||||
tags, ok := ixc.columnNamesToTags(cols)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("the table does not contain at least one of the following columns: `%v`", cols)
|
||||
}
|
||||
return ixc.AddIndexByColTags(indexName, tags, props)
|
||||
return ixc.AddIndexByColTags(indexName, tags, prefixLengths, props)
|
||||
}
|
||||
|
||||
func (ixc *indexCollectionImpl) AddIndexByColTags(indexName string, tags []uint64, props IndexProperties) (Index, error) {
|
||||
func (ixc *indexCollectionImpl) AddIndexByColTags(indexName string, tags []uint64, prefixLengths []uint16, props IndexProperties) (Index, error) {
|
||||
if strings.HasPrefix(indexName, "dolt_") {
|
||||
return nil, fmt.Errorf("indexes cannot be prefixed with `dolt_`")
|
||||
}
|
||||
@@ -163,7 +161,7 @@ func (ixc *indexCollectionImpl) AddIndexByColTags(indexName string, tags []uint6
|
||||
isUnique: props.IsUnique,
|
||||
isUserDefined: props.IsUserDefined,
|
||||
comment: props.Comment,
|
||||
prefixLengths: []uint16{},
|
||||
prefixLengths: prefixLengths,
|
||||
}
|
||||
ixc.indexes[indexName] = index
|
||||
for _, tag := range tags {
|
||||
@@ -180,7 +178,7 @@ func validateColumnIndexable(c Column) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ixc *indexCollectionImpl) UnsafeAddIndexByColTags(indexName string, tags []uint64, props IndexProperties) (Index, error) {
|
||||
func (ixc *indexCollectionImpl) UnsafeAddIndexByColTags(indexName string, tags []uint64, prefixLengths []uint16, props IndexProperties) (Index, error) {
|
||||
index := &indexImpl{
|
||||
indexColl: ixc,
|
||||
name: indexName,
|
||||
@@ -189,6 +187,7 @@ func (ixc *indexCollectionImpl) UnsafeAddIndexByColTags(indexName string, tags [
|
||||
isUnique: props.IsUnique,
|
||||
isUserDefined: props.IsUserDefined,
|
||||
comment: props.Comment,
|
||||
prefixLengths: prefixLengths,
|
||||
}
|
||||
ixc.indexes[indexName] = index
|
||||
for _, tag := range tags {
|
||||
@@ -328,7 +327,7 @@ func (ixc *indexCollectionImpl) Merge(indexes ...Index) {
|
||||
isUnique: index.IsUnique(),
|
||||
isUserDefined: index.IsUserDefined(),
|
||||
comment: index.Comment(),
|
||||
prefixLengths: index.GetPrefixLengths(),
|
||||
prefixLengths: index.PrefixLengths(),
|
||||
}
|
||||
ixc.AddIndex(newIndex)
|
||||
}
|
||||
@@ -432,14 +431,6 @@ func (ixc *indexCollectionImpl) SetPks(tags []uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ixc *indexCollectionImpl) SetIndexPrefixLength(indexName string, prefixLengths []uint16) error {
|
||||
if !ixc.Contains(indexName) {
|
||||
return fmt.Errorf("`%s` does not exist as an index for this table", indexName)
|
||||
}
|
||||
ixc.indexes[indexName].prefixLengths = prefixLengths
|
||||
return nil
|
||||
}
|
||||
|
||||
func combineAllTags(tags []uint64, pks []uint64) []uint64 {
|
||||
allTags := make([]uint64, len(tags))
|
||||
_ = copy(allTags, tags)
|
||||
|
||||
@@ -265,11 +265,15 @@ func replaceColumnInSchema(sch schema.Schema, oldCol schema.Column, newCol schem
|
||||
tags[i] = newCol.Tag
|
||||
}
|
||||
}
|
||||
_, err = newSch.Indexes().AddIndexByColTags(index.Name(), tags, schema.IndexProperties{
|
||||
IsUnique: index.IsUnique(),
|
||||
IsUserDefined: index.IsUserDefined(),
|
||||
Comment: index.Comment(),
|
||||
})
|
||||
_, err = newSch.Indexes().AddIndexByColTags(
|
||||
index.Name(),
|
||||
tags,
|
||||
index.PrefixLengths(),
|
||||
schema.IndexProperties{
|
||||
IsUnique: index.IsUnique(),
|
||||
IsUserDefined: index.IsUserDefined(),
|
||||
Comment: index.Comment(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func validateIndexConsistency(
|
||||
primary, secondary prolly.Map,
|
||||
) error {
|
||||
// TODO: fix this later
|
||||
if len(def.GetPrefixLengths()) > 0 {
|
||||
if len(def.PrefixLengths()) > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ func getSecondaryIndex(ctx context.Context, db, tbl string, t *doltdb.Table, sch
|
||||
order: sql.IndexOrderAsc,
|
||||
constrainedToLookupExpression: true,
|
||||
doltBinFormat: types.IsFormat_DOLT(vrw.Format()),
|
||||
prefixLengths: idx.GetPrefixLengths(),
|
||||
prefixLengths: idx.PrefixLengths(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1342,11 +1342,15 @@ func (t *AlterableDoltTable) RewriteInserter(
|
||||
colNames = append(colNames, colName)
|
||||
}
|
||||
}
|
||||
newSch.Indexes().AddIndexByColNames(index.Name(), colNames, schema.IndexProperties{
|
||||
IsUnique: index.IsUnique(),
|
||||
IsUserDefined: index.IsUserDefined(),
|
||||
Comment: index.Comment(),
|
||||
})
|
||||
newSch.Indexes().AddIndexByColNames(
|
||||
index.Name(),
|
||||
colNames,
|
||||
index.PrefixLengths(),
|
||||
schema.IndexProperties{
|
||||
IsUnique: index.IsUnique(),
|
||||
IsUserDefined: index.IsUserDefined(),
|
||||
Comment: index.Comment(),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
newSch = schema.CopyIndexes(oldSch, newSch)
|
||||
|
||||
@@ -79,7 +79,7 @@ func getSecondaryProllyIndexWriters(ctx context.Context, t *doltdb.Table, sqlSch
|
||||
// mapping from secondary index key to primary key
|
||||
pkMap := makeIndexToIndexMapping(def.Schema().GetPKCols(), sch.GetPKCols())
|
||||
|
||||
prefixLengths := def.GetPrefixLengths()
|
||||
prefixLengths := def.PrefixLengths()
|
||||
if len(prefixLengths) == 0 {
|
||||
writers[defName] = prollySecondaryIndexWriter{
|
||||
name: defName,
|
||||
@@ -130,7 +130,7 @@ func getSecondaryKeylessProllyWriters(ctx context.Context, t *doltdb.Table, sqlS
|
||||
keyMap, _ := ordinalMappingsFromSchema(sqlSch, def.Schema())
|
||||
keyDesc, _ := m.Descriptors()
|
||||
|
||||
prefixLengths := def.GetPrefixLengths()
|
||||
prefixLengths := def.PrefixLengths()
|
||||
if len(prefixLengths) == 0 {
|
||||
writers[defName] = prollyKeylessSecondaryWriter{
|
||||
name: defName,
|
||||
|
||||
@@ -97,9 +97,10 @@ func CreateIndex(
|
||||
}
|
||||
|
||||
// create the index metadata, will error if index names are taken or an index with the same columns in the same order exists
|
||||
_, err = sch.Indexes().AddIndexByColNames(
|
||||
index, err := sch.Indexes().AddIndexByColNames(
|
||||
indexName,
|
||||
realColNames,
|
||||
prefixLengths,
|
||||
schema.IndexProperties{
|
||||
IsUnique: isUnique,
|
||||
IsUserDefined: isUserDefined,
|
||||
@@ -110,11 +111,6 @@ func CreateIndex(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = sch.Indexes().SetIndexPrefixLength(indexName, prefixLengths)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// update the table schema with the new index
|
||||
newTable, err := table.UpdateSchema(ctx, sch)
|
||||
if err != nil {
|
||||
@@ -123,7 +119,6 @@ func CreateIndex(
|
||||
|
||||
// TODO: in the case that we're replacing an implicit index with one the user specified, we could do this more
|
||||
// cheaply in some cases by just renaming it, rather than building it from scratch. But that's harder to get right.
|
||||
index := sch.Indexes().GetByName(indexName)
|
||||
indexRows, err := BuildSecondaryIndex(ctx, newTable, index, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestIndexEditorConcurrency(t *testing.T) {
|
||||
schema.NewColumn("v2", 2, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_concurrency", []string{"v1"}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_concurrency", []string{"v1"}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
indexSch := index.Schema()
|
||||
emptyMap, err := types.NewMap(context.Background(), vrw)
|
||||
@@ -158,7 +158,7 @@ func TestIndexEditorConcurrencyPostInsert(t *testing.T) {
|
||||
schema.NewColumn("v2", 2, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_concurrency", []string{"v1"}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_concurrency", []string{"v1"}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
indexSch := index.Schema()
|
||||
emptyMap, err := types.NewMap(context.Background(), vrw)
|
||||
@@ -250,7 +250,7 @@ func TestIndexEditorUniqueMultipleNil(t *testing.T) {
|
||||
schema.NewColumn("v1", 1, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_unique", []string{"v1"}, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_unique", []string{"v1"}, nil, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
indexSch := index.Schema()
|
||||
emptyMap, err := types.NewMap(context.Background(), vrw)
|
||||
@@ -297,7 +297,7 @@ func TestIndexEditorWriteAfterFlush(t *testing.T) {
|
||||
schema.NewColumn("v2", 2, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_concurrency", []string{"v1"}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_concurrency", []string{"v1"}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
indexSch := index.Schema()
|
||||
emptyMap, err := types.NewMap(context.Background(), vrw)
|
||||
@@ -365,7 +365,7 @@ func TestIndexEditorUniqueErrorDoesntPersist(t *testing.T) {
|
||||
schema.NewColumn("v1", 1, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_unq", []string{"v1"}, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_unq", []string{"v1"}, nil, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
indexSch := index.Schema()
|
||||
emptyMap, err := types.NewMap(context.Background(), vrw)
|
||||
@@ -618,7 +618,7 @@ func TestIndexRebuildingUniqueSuccessOneCol(t *testing.T) {
|
||||
originalTable, err := createTableWithoutIndexRebuilding(context.Background(), vrw, ns, sch, rowData)
|
||||
require.NoError(t, err)
|
||||
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2}, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2}, nil, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
updatedTable, err := originalTable.UpdateSchema(context.Background(), sch)
|
||||
require.NoError(t, err)
|
||||
@@ -649,7 +649,7 @@ func TestIndexRebuildingUniqueSuccessTwoCol(t *testing.T) {
|
||||
originalTable, err := createTableWithoutIndexRebuilding(context.Background(), vrw, ns, sch, rowData)
|
||||
require.NoError(t, err)
|
||||
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2, 3}, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2, 3}, nil, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
updatedTable, err := originalTable.UpdateSchema(context.Background(), sch)
|
||||
require.NoError(t, err)
|
||||
@@ -680,7 +680,7 @@ func TestIndexRebuildingUniqueFailOneCol(t *testing.T) {
|
||||
originalTable, err := createTableWithoutIndexRebuilding(context.Background(), vrw, ns, sch, rowData)
|
||||
require.NoError(t, err)
|
||||
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2}, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2}, nil, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
updatedTable, err := originalTable.UpdateSchema(context.Background(), sch)
|
||||
require.NoError(t, err)
|
||||
@@ -712,7 +712,7 @@ func TestIndexRebuildingUniqueFailTwoCol(t *testing.T) {
|
||||
originalTable, err := createTableWithoutIndexRebuilding(context.Background(), vrw, ns, sch, rowData)
|
||||
require.NoError(t, err)
|
||||
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2, 3}, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
index, err := sch.Indexes().AddIndexByColTags("idx_v1", []uint64{2, 3}, nil, schema.IndexProperties{IsUnique: true, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
updatedTable, err := originalTable.UpdateSchema(context.Background(), sch)
|
||||
require.NoError(t, err)
|
||||
@@ -738,7 +738,7 @@ func TestIndexEditorCapacityExceeded(t *testing.T) {
|
||||
schema.NewColumn("v1", 1, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_cap", []string{"v1"}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
index, err := tableSch.Indexes().AddIndexByColNames("idx_cap", []string{"v1"}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
indexSch := index.Schema()
|
||||
emptyMap, err := types.NewMap(ctx, vrw)
|
||||
@@ -837,9 +837,9 @@ func createTestSchema(t *testing.T) schema.Schema {
|
||||
)
|
||||
sch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexName, []uint64{firstTag, lastTag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexName, []uint64{firstTag, lastTag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexAge, []uint64{ageTag}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
_, err = sch.Indexes().AddIndexByColTags(testSchemaIndexAge, []uint64{ageTag}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
require.NoError(t, err)
|
||||
return sch
|
||||
}
|
||||
|
||||
@@ -426,11 +426,11 @@ func TestKeylessTableEditorMultipleIndexErrorHandling(t *testing.T) {
|
||||
schema.NewColumn("v2", 2, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
idxv1, err := tableSch.Indexes().AddIndexByColNames("idx_v1", []string{"v1"}, schema.IndexProperties{
|
||||
idxv1, err := tableSch.Indexes().AddIndexByColNames("idx_v1", []string{"v1"}, nil, schema.IndexProperties{
|
||||
IsUnique: false,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
idxv2, err := tableSch.Indexes().AddIndexByColNames("idx_v2", []string{"v2"}, schema.IndexProperties{
|
||||
idxv2, err := tableSch.Indexes().AddIndexByColNames("idx_v2", []string{"v2"}, nil, schema.IndexProperties{
|
||||
IsUnique: false,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -583,7 +583,7 @@ func TestKeylessTableEditorIndexCardinality(t *testing.T) {
|
||||
schema.NewColumn("v2", 2, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
idxv1, err := tableSch.Indexes().AddIndexByColNames("idx_v1", []string{"v1"}, schema.IndexProperties{
|
||||
idxv1, err := tableSch.Indexes().AddIndexByColNames("idx_v1", []string{"v1"}, nil, schema.IndexProperties{
|
||||
IsUnique: false,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -392,11 +392,11 @@ func TestTableEditorMultipleIndexErrorHandling(t *testing.T) {
|
||||
schema.NewColumn("v2", 2, types.IntKind, false))
|
||||
tableSch, err := schema.SchemaFromCols(colColl)
|
||||
require.NoError(t, err)
|
||||
idxv1, err := tableSch.Indexes().AddIndexByColNames("idx_v1", []string{"v1"}, schema.IndexProperties{
|
||||
idxv1, err := tableSch.Indexes().AddIndexByColNames("idx_v1", []string{"v1"}, nil, schema.IndexProperties{
|
||||
IsUnique: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
idxv2, err := tableSch.Indexes().AddIndexByColNames("idx_v2", []string{"v2"}, schema.IndexProperties{
|
||||
idxv2, err := tableSch.Indexes().AddIndexByColNames("idx_v2", []string{"v2"}, nil, schema.IndexProperties{
|
||||
IsUnique: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user