Implement StatisticsTable interface to provide table statistics to the analyzer. (#1269)

This commit is contained in:
Brian Hendriks
2021-01-28 13:54:15 -08:00
committed by GitHub
parent 73a30bc154
commit 056195db2b
5 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ require (
github.com/denisbrodbeck/machineid v1.0.1
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20201005193433-3ee972b1d078
github.com/dolthub/fslock v0.0.2
github.com/dolthub/go-mysql-server v0.6.1-0.20210123015423-91ba339638c5
github.com/dolthub/go-mysql-server v0.6.1-0.20210128193608-1e05f33bb02a
github.com/dolthub/ishell v0.0.0-20201107004254-1592c0036c8d
github.com/dolthub/mmap-go v1.0.4-0.20201107010347-f9f2a9588a66
github.com/dolthub/sqllogictest/go v0.0.0-20201105013724-5123fc66e12c
+2 -2
View File
@@ -148,8 +148,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/dolthub/fslock v0.0.2 h1:8vUh47iKovgrtXNrXVIzsIoWLlspoXg+3nslhUzgKSw=
github.com/dolthub/fslock v0.0.2/go.mod h1:0i7bsNkK+XHwFL3dIsSWeXSV7sykVzzVr6+jq8oeEo0=
github.com/dolthub/go-mysql-server v0.6.1-0.20210123015423-91ba339638c5 h1:CleRsi58QnKJysBoGJIPaIuyOHb4kfX/mWkriVdzXKE=
github.com/dolthub/go-mysql-server v0.6.1-0.20210123015423-91ba339638c5/go.mod h1:MRKd4z13XtaT7yLEx2GtR1IIt3WHXVqkzNvYD7WXt3o=
github.com/dolthub/go-mysql-server v0.6.1-0.20210128193608-1e05f33bb02a h1:D07spJ3nb2FP5CqBqLL1c93Rsyf554pDGybVZgy4Uko=
github.com/dolthub/go-mysql-server v0.6.1-0.20210128193608-1e05f33bb02a/go.mod h1:MRKd4z13XtaT7yLEx2GtR1IIt3WHXVqkzNvYD7WXt3o=
github.com/dolthub/ishell v0.0.0-20201107004254-1592c0036c8d h1:i0u1Ze9wZF/zLgyOB/aLkG01gDDNQ48PR0/a80mxEyQ=
github.com/dolthub/ishell v0.0.0-20201107004254-1592c0036c8d/go.mod h1:dhGBqcCEfK5kuFmeO5+WOx3hqc1k3M29c1oS/R7N4ms=
github.com/dolthub/mmap-go v1.0.4-0.20201107010347-f9f2a9588a66 h1:WRPDbpJWEnPxPmiuOTndT+lUWUeGjx6eoNOK9O4tQQQ=
@@ -206,6 +206,7 @@ func TestDropColumn(t *testing.T) {
}
func TestCreateForeignKeys(t *testing.T) {
t.Skipf("Unsupported")
enginetest.TestCreateForeignKeys(t, newDoltHarness(t))
}
@@ -114,6 +114,7 @@ var _ sql.IndexedTable = (*WritableIndexedDoltTable)(nil)
var _ sql.UpdatableTable = (*WritableIndexedDoltTable)(nil)
var _ sql.DeletableTable = (*WritableIndexedDoltTable)(nil)
var _ sql.ReplaceableTable = (*WritableIndexedDoltTable)(nil)
var _ sql.StatisticsTable = (*WritableIndexedDoltTable)(nil)
type WritableIndexedDoltTable struct {
*WritableDoltTable
@@ -131,6 +132,17 @@ func (t *WritableIndexedDoltTable) PartitionRows(ctx *sql.Context, part sql.Part
return partitionIndexedTableRows(ctx, t, nil, part)
}
// NumRows returns the unfiltered count of rows contained in the table
func (t *WritableIndexedDoltTable) NumRows(ctx *sql.Context) (uint64, error) {
m, err := t.table.GetRowData(ctx)
if err != nil {
return 0, err
}
return m.Len(), nil
}
func partitionIndexedTableRows(ctx *sql.Context, t *WritableIndexedDoltTable, projectedCols []string, part sql.Partition) (sql.RowIter, error) {
switch typed := part.(type) {
case rangePartition:
+12
View File
@@ -102,6 +102,7 @@ func NewDoltTable(name string, sch schema.Schema, tbl *doltdb.Table, db SqlDatab
var _ sql.Table = (*DoltTable)(nil)
var _ sql.IndexedTable = (*DoltTable)(nil)
var _ sql.ForeignKeyTable = (*DoltTable)(nil)
var _ sql.StatisticsTable = (*DoltTable)(nil)
// projected tables disabled for now. Looks like some work needs to be done in the analyzer as there are cases
// where the projected columns do not contain every column needed. Seed this with natural and other joins. There
@@ -199,6 +200,17 @@ func (t *DoltTable) String() string {
return t.name
}
// NumRows returns the unfiltered count of rows contained in the table
func (t *DoltTable) NumRows(ctx *sql.Context) (uint64, error) {
m, err := t.table.GetRowData(ctx)
if err != nil {
return 0, err
}
return m.Len(), nil
}
// Schema returns the schema for this table.
func (t *DoltTable) Schema() sql.Schema {
return t.sqlSchema()