mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-24 19:48:41 -05:00
[no-release-notes] more stats tests (#8361)
* [no-release-notes] tests for varbinary stats * bump * bump * mcv row types fix * fix bats * nick's comments * [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --------- Co-authored-by: max-hoffman <max-hoffman@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3fa40fbaa0
commit
747985d73a
@@ -22,7 +22,7 @@ require (
|
||||
github.com/go-sql-driver/mysql v1.7.2-0.20231213112541-0004702b931d
|
||||
github.com/gocraft/dbr/v2 v2.7.2
|
||||
github.com/golang/snappy v0.0.4
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/jpillora/backoff v1.0.0
|
||||
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d
|
||||
github.com/mattn/go-isatty v0.0.17
|
||||
@@ -57,7 +57,7 @@ require (
|
||||
github.com/cespare/xxhash/v2 v2.2.0
|
||||
github.com/creasty/defaults v1.6.0
|
||||
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
|
||||
github.com/dolthub/go-mysql-server v0.18.2-0.20240917100606-3acd341e555c
|
||||
github.com/dolthub/go-mysql-server v0.18.2-0.20240917161933-32eff493e467
|
||||
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
|
||||
github.com/dolthub/swiss v0.1.0
|
||||
github.com/goccy/go-json v0.10.2
|
||||
|
||||
@@ -183,8 +183,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
|
||||
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA=
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
|
||||
github.com/dolthub/go-mysql-server v0.18.2-0.20240917100606-3acd341e555c h1:wAMoQuahh3u7cZtV+9NmE7dDGjfKNb5PyyBSF8x27Gw=
|
||||
github.com/dolthub/go-mysql-server v0.18.2-0.20240917100606-3acd341e555c/go.mod h1:m88EMm9OthVVa6qIhbpnRDpj/eYUXuNpvY/+0YWKVwc=
|
||||
github.com/dolthub/go-mysql-server v0.18.2-0.20240917161933-32eff493e467 h1:Q1VtNuqdXiCDVdCpuOrqxHCAQaHtkHe8HMBejNQz5gc=
|
||||
github.com/dolthub/go-mysql-server v0.18.2-0.20240917161933-32eff493e467/go.mod h1:m88EMm9OthVVa6qIhbpnRDpj/eYUXuNpvY/+0YWKVwc=
|
||||
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
|
||||
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
|
||||
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
|
||||
@@ -362,8 +362,8 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
|
||||
@@ -348,6 +348,49 @@ var DoltStatsIOTests = []queries.ScriptTest{
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "binary types round-trip",
|
||||
SetUpScript: []string{
|
||||
"CREATE table xy (x bigint primary key, y varbinary(10), z binary(14), key(y(9)), key(z));",
|
||||
"insert into xy values (0,'row 1', 'row 1'),(1,'row 2', 'row 1')",
|
||||
"analyze table xy",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select database_name, table_name, index_name, columns, types from dolt_statistics",
|
||||
Expected: []sql.Row{
|
||||
{"mydb", "xy", "y", "y", "varbinary(10)"},
|
||||
{"mydb", "xy", "primary", "x", "bigint"},
|
||||
{"mydb", "xy", "z", "z", "binary(14)"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Query: "select count(*) from dolt_statistics",
|
||||
Expected: []sql.Row{{3}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "timestamp types round-trip",
|
||||
SetUpScript: []string{
|
||||
"CREATE table xy (x bigint primary key, y timestamp, key(y));",
|
||||
"insert into xy values (0,'2024-03-11 18:52:44'),(1,'2024-03-11 19:22:12')",
|
||||
"analyze table xy",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "select database_name, table_name, index_name, columns, types from dolt_statistics",
|
||||
Expected: []sql.Row{
|
||||
{"mydb", "xy", "primary", "x", "bigint"},
|
||||
{"mydb", "xy", "y", "y", "timestamp"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Query: "select count(*) from dolt_statistics",
|
||||
Expected: []sql.Row{{2}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "multi-table",
|
||||
SetUpScript: []string{
|
||||
|
||||
@@ -222,6 +222,11 @@ func loadLowerBound(ctx *sql.Context, qual sql.StatQualifier) (sql.Row, error) {
|
||||
keyBuilder := val.NewTupleBuilder(prollyMap.KeyDesc())
|
||||
buffPool := prollyMap.NodeStore().Pool()
|
||||
|
||||
if cnt, err := prollyMap.Count(); err != nil {
|
||||
return nil, err
|
||||
} else if cnt == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
firstIter, err := prollyMap.IterOrdinalRange(ctx, 0, 1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/dolthub/go-mysql-server/sql/stats"
|
||||
"github.com/dolthub/go-mysql-server/sql/types"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/statspro"
|
||||
@@ -34,6 +35,8 @@ import (
|
||||
// of the expected size.
|
||||
const maxBucketFanout = 200 * 200
|
||||
|
||||
var mcvsTypes = []sql.Type{types.Int64, types.Int64, types.Int64}
|
||||
|
||||
func (n *NomsStatsDatabase) replaceStats(ctx context.Context, statsMap *prolly.MutableMap, dStats *statspro.DoltStats) error {
|
||||
if err := deleteIndexRows(ctx, statsMap, dStats); err != nil {
|
||||
return err
|
||||
@@ -127,7 +130,7 @@ func putIndexRows(ctx context.Context, statsMap *prolly.MutableMap, dStats *stat
|
||||
for _, v := range h.McvCounts() {
|
||||
mcvCntsRow = append(mcvCntsRow, int(v))
|
||||
}
|
||||
valueBuilder.PutString(14, stats.StringifyKey(mcvCntsRow, dStats.Statistic.Typs))
|
||||
valueBuilder.PutString(14, stats.StringifyKey(mcvCntsRow, mcvsTypes))
|
||||
|
||||
key := keyBuilder.Build(pool)
|
||||
value := valueBuilder.Build(pool)
|
||||
|
||||
@@ -133,7 +133,7 @@ func (p *Provider) Load(ctx *sql.Context, fs filesys.Filesys, db dsess.SqlDataba
|
||||
// |statPath| is either file://./stat or mem://stat
|
||||
statsDb, err := p.sf.Init(ctx, db, p.pro, fs, env.GetCurrentUserHomeDir)
|
||||
if err != nil {
|
||||
ctx.Warn(0, err.Error())
|
||||
ctx.GetLogger().Errorf("initialize stats failure: %s\n", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func (p *Provider) Load(ctx *sql.Context, fs filesys.Filesys, db dsess.SqlDataba
|
||||
if err != nil {
|
||||
// if branch name is invalid, continue loading rest
|
||||
// TODO: differentiate bad branch name from other errors
|
||||
ctx.Warn(0, err.Error())
|
||||
ctx.GetLogger().Errorf("load stats failure: %s\n", err.Error())
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user