Bug fix, removed some unused methods

This commit is contained in:
Zach Musgrave
2022-11-02 14:50:37 -07:00
parent 461130c30c
commit 19cccb888b
2 changed files with 4 additions and 45 deletions
+3 -11
View File
@@ -51,6 +51,7 @@ var typedColColl = schema.NewColCollection(
schema.NewColumn("title", TitleTag, types.StringKind, false),
)
// Schema returns the schema for the `people` test table.
func Schema() (schema.Schema, error) {
sch := schema.MustSchemaFromCols(typedColColl)
@@ -67,13 +68,14 @@ func Schema() (schema.Schema, error) {
return sch, err
}
// RowsAndSchema returns the schema and rows for the `people` test table.
func RowsAndSchema() ([]row.Row, schema.Schema, error) {
rows := make([]row.Row, len(UUIDS))
sch, err := Schema()
if err != nil {
return nil, nil, err
}
rows := make([]row.Row, len(UUIDS))
for i := 0; i < len(UUIDS); i++ {
married := types.Int(0)
if MaritalStatus[i] {
@@ -96,16 +98,6 @@ func RowsAndSchema() ([]row.Row, schema.Schema, error) {
rows = append(rows, r)
}
_, err = sch.Indexes().AddIndexByColTags(IndexName, []uint64{NameTag}, schema.IndexProperties{IsUnique: false, Comment: ""})
if err != nil {
return nil, nil, err
}
_, err = sch.Checks().AddCheck("test-check", "age < 123", true)
if err != nil {
return nil, nil, err
}
return rows, sch, err
}
+1 -34
View File
@@ -15,12 +15,9 @@
package dtestutils
import (
"math"
"github.com/dolthub/dolt/go/libraries/doltcore/row"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
"github.com/dolthub/dolt/go/store/types"
"github.com/google/go-cmp/cmp"
)
// CreateSchema returns a schema from the columns given, panicking on any errors.
@@ -31,7 +28,7 @@ func CreateSchema(columns ...schema.Column) schema.Schema {
return sch
}
// Creates a row with the schema given, having the values given. Starts at tag 0 and counts up.
// NewRow creates a row with the schema given, having the values given. Starts at tag 0 and counts up.
func NewRow(sch schema.Schema, values ...types.Value) row.Row {
taggedVals := make(row.TaggedValues)
for i := range values {
@@ -58,36 +55,6 @@ func AddColumnToSchema(sch schema.Schema, col schema.Column) schema.Schema {
return newSch
}
// RemoveColumnFromSchema returns a new schema with the given tag missing, but otherwise identical. At least one
// primary column must remain.
func RemoveColumnFromSchema(sch schema.Schema, tagToRemove uint64) schema.Schema {
var newCols []schema.Column
err := sch.GetAllCols().Iter(func(tag uint64, col schema.Column) (stop bool, err error) {
if tag != tagToRemove {
newCols = append(newCols, col)
}
return false, nil
})
if err != nil {
panic(err)
}
columns := schema.NewColCollection(newCols...)
newSch := schema.MustSchemaFromCols(columns)
newSch.SetCollation(sch.GetCollation())
return newSch
}
// Compares two noms Floats for approximate equality
var FloatComparer = cmp.Comparer(func(x, y types.Float) bool {
return math.Abs(float64(x)-float64(y)) < .001
})
var TimestampComparer = cmp.Comparer(func(x, y types.Timestamp) bool {
return x.Equals(y)
})
// MustSchema takes a variable number of columns and returns a schema.
func MustSchema(cols ...schema.Column) schema.Schema {
hasPKCols := false