mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-23 13:48:42 -05:00
[no-release-notes] Pushdown refactor, deprecate sql.FilteredTable, ColumnDiffTable correctness (#6024)
* [no-release-notes] Pushdown refactor, deprecate sql.FilteredTable, ColumnDiffTable correctness Pushdown splitting into two phases uncovered bugs. sql.FilteredTable is now deprecated. ColumnDiffTable correctness tests were never run through the indexing path before, which are broken. This disables the indexing path and runs the proper test suites. * [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh * bump * tidy * missing interface method * mod tidy * formatter --------- Co-authored-by: max-hoffman <max-hoffman@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
cf301fc940
commit
0bfd57ae4d
Generated
+2
-2
@@ -7663,7 +7663,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2020-2021 wazero authors
|
||||
Copyright 2020-2023 wazero authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -7677,7 +7677,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
= LICENSE 06e378fe3dca2626ad24b9814356eb2d02a762c13234b0d13cf821e0 =
|
||||
= LICENSE 8688e1eec2a64837c6b20e1134bfa84e33dffb6a1e80afaf23c216c3 =
|
||||
================================================================================
|
||||
|
||||
================================================================================
|
||||
|
||||
@@ -36,7 +36,7 @@ require (
|
||||
github.com/silvasur/buzhash v0.0.0-20160816060738-9bdec3dec7c6
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
|
||||
github.com/stretchr/testify v1.8.1
|
||||
github.com/stretchr/testify v1.8.2
|
||||
github.com/tealeg/xlsx v1.0.5
|
||||
github.com/tklauser/go-sysconf v0.3.9 // indirect
|
||||
go.uber.org/zap v1.15.0
|
||||
@@ -59,7 +59,7 @@ require (
|
||||
github.com/cespare/xxhash v1.1.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.15.1-0.20230523172851-5ecfc1bc2af0
|
||||
github.com/dolthub/go-mysql-server v0.15.1-0.20230524212617-915ab8e09277
|
||||
github.com/dolthub/swiss v0.1.0
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.2
|
||||
@@ -96,7 +96,7 @@ require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20230516121657-5424676dd4ac // indirect
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e // indirect
|
||||
github.com/dolthub/jsonpath v0.0.1 // indirect
|
||||
github.com/dolthub/maphash v0.0.0-20221220182448-74e1e1ea1577 // indirect
|
||||
github.com/go-fonts/liberation v0.2.0 // indirect
|
||||
@@ -127,7 +127,7 @@ require (
|
||||
github.com/prometheus/common v0.37.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/rs/xid v1.4.0 // indirect
|
||||
github.com/tetratelabs/wazero v1.0.3 // indirect
|
||||
github.com/tetratelabs/wazero v1.1.0 // indirect
|
||||
github.com/tidwall/gjson v1.14.4 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
|
||||
@@ -166,10 +166,10 @@ github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1G
|
||||
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2/go.mod h1:mIEZOHnFx4ZMQeawhw9rhsj+0zwQj7adVsnBX7t+eKY=
|
||||
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-20230516121657-5424676dd4ac h1:/bsG4AyV5MesUPw7LSkxHKMsP9f+LSLrsMbBxLP6+Mk=
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20230516121657-5424676dd4ac/go.mod h1:xLKpPutKiF9FxxcLG3gf/JA95YZQNAqBegkDRe1AZF4=
|
||||
github.com/dolthub/go-mysql-server v0.15.1-0.20230523172851-5ecfc1bc2af0 h1:UGMgP9QkOW3kk566+307dZSHAOyDk0jt/AEu1liWOfs=
|
||||
github.com/dolthub/go-mysql-server v0.15.1-0.20230523172851-5ecfc1bc2af0/go.mod h1:QtEmore89AqJ0j039nSXGKpOUbzx9+LRuwrnfd4sua8=
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e h1:kPsT4a47cw1+y/N5SSCkma7FhAPw7KeGmD6c9PBZW9Y=
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
|
||||
github.com/dolthub/go-mysql-server v0.15.1-0.20230524212617-915ab8e09277 h1:W3ZlSJICyeT4SOKY4YLqNgpQDcjC4oRulpbWuVoUvU8=
|
||||
github.com/dolthub/go-mysql-server v0.15.1-0.20230524212617-915ab8e09277/go.mod h1:Mf2jCPvtE9GzjWaVfPpOBCWCLtw6Up21xkrKDW8H/aM=
|
||||
github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488 h1:0HHu0GWJH0N6a6keStrHhUAK5/o9LVfkh44pvsV4514=
|
||||
github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488/go.mod h1:ehexgi1mPxRTk0Mok/pADALuHbvATulTh6gzr7NzZto=
|
||||
github.com/dolthub/jsonpath v0.0.1 h1:Nd+T3U+XisK3kOuxtABS5IIbZqXVIlOR9VYquyjQ0u0=
|
||||
@@ -623,12 +623,12 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
|
||||
github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
|
||||
github.com/tetratelabs/wazero v1.0.3 h1:IWmaxc/5vKg71DE+c0SLjjLFAA3u3tD/Zegpgif2Wpo=
|
||||
github.com/tetratelabs/wazero v1.0.3/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
|
||||
github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ=
|
||||
github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
|
||||
github.com/thepudds/swisstable v0.0.0-20221011152303-9c77dc657777 h1:5u+6YWU2faS+Sr/x8j9yalMpSDUkatNOZWXV3wMUCGQ=
|
||||
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||
|
||||
@@ -35,8 +35,6 @@ import (
|
||||
dtypes "github.com/dolthub/dolt/go/store/types"
|
||||
)
|
||||
|
||||
var _ sql.FilteredTable = (*ColumnDiffTable)(nil)
|
||||
|
||||
// ColumnDiffTable is a sql.Table implementation of a system table that shows which tables and columns have
|
||||
// changed in each commit, across all branches.
|
||||
type ColumnDiffTable struct {
|
||||
@@ -78,29 +76,6 @@ func (dt *ColumnDiffTable) Schema() sql.Schema {
|
||||
}
|
||||
}
|
||||
|
||||
// Filters returns the list of filters that are applied to this table.
|
||||
func (dt *ColumnDiffTable) Filters() []sql.Expression {
|
||||
return dt.partitionFilters
|
||||
}
|
||||
|
||||
// HandledFilters returns the list of filters that will be handled by the table itself
|
||||
func (dt *ColumnDiffTable) HandledFilters(filters []sql.Expression) []sql.Expression {
|
||||
filters = append(filters, dt.partitionFilters...)
|
||||
dt.partitionFilters = FilterFilters(filters, ColumnPredicate(filterColumnNameSet))
|
||||
return dt.partitionFilters
|
||||
}
|
||||
|
||||
// WithFilters returns a new sql.Table instance with the filters applied
|
||||
func (dt *ColumnDiffTable) WithFilters(_ *sql.Context, filters []sql.Expression) sql.Table {
|
||||
dt.partitionFilters = FilterFilters(filters, ColumnPredicate(filterColumnNameSet))
|
||||
commitCheck, err := commitFilterForDiffTableFilterExprs(dt.partitionFilters)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
dt.commitCheck = commitCheck
|
||||
return dt
|
||||
}
|
||||
|
||||
// Partitions is a sql.Table interface function that returns a partition of the data. Returns one
|
||||
// partition for working set changes and one partition for all commit history.
|
||||
func (dt *ColumnDiffTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error) {
|
||||
@@ -134,16 +109,17 @@ func (dt *ColumnDiffTable) PartitionRows(ctx *sql.Context, partition sql.Partiti
|
||||
}
|
||||
}
|
||||
|
||||
//todo fix indexed paths, these were missing tests in CI
|
||||
// GetIndexes implements sql.IndexAddressable
|
||||
func (dt *ColumnDiffTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error) {
|
||||
return index.DoltCommitIndexes(dt.Name(), dt.ddb, true)
|
||||
}
|
||||
//func (dt *ColumnDiffTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error) {
|
||||
// return index.DoltCommitIndexes(dt.Name(), dt.ddb, true)
|
||||
//}
|
||||
|
||||
// IndexedAccess implements sql.IndexAddressable
|
||||
func (dt *ColumnDiffTable) IndexedAccess(lookup sql.IndexLookup) sql.IndexedTable {
|
||||
nt := *dt
|
||||
return &nt
|
||||
}
|
||||
//func (dt *ColumnDiffTable) IndexedAccess(lookup sql.IndexLookup) sql.IndexedTable {
|
||||
// nt := *dt
|
||||
// return &nt
|
||||
//}
|
||||
|
||||
// Collation implements the sql.Table interface.
|
||||
func (dt *ColumnDiffTable) Collation() sql.CollationID {
|
||||
|
||||
@@ -22,29 +22,31 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/dolthub/go-mysql-server/sql/expression"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/rowconv"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
)
|
||||
|
||||
var ErrExactlyOneToCommit = errors.New("dolt_commit_diff_* tables must be filtered to a single 'to_commit'")
|
||||
var ErrExactlyOneFromCommit = errors.New("dolt_commit_diff_* tables must be filtered to a single 'from_commit'")
|
||||
var ErrInvalidCommitDiffTableArgs = errors.New("commit_diff_<table> requires one 'to_commit' and one 'from_commit'")
|
||||
|
||||
var _ sql.Table = (*CommitDiffTable)(nil)
|
||||
var _ sql.FilteredTable = (*CommitDiffTable)(nil)
|
||||
|
||||
type CommitDiffTable struct {
|
||||
name string
|
||||
ddb *doltdb.DoltDB
|
||||
joiner *rowconv.Joiner
|
||||
sqlSch sql.PrimaryKeySchema
|
||||
workingRoot *doltdb.RootValue
|
||||
fromCommitFilter *expression.Equals
|
||||
toCommitFilter *expression.Equals
|
||||
name string
|
||||
ddb *doltdb.DoltDB
|
||||
joiner *rowconv.Joiner
|
||||
sqlSch sql.PrimaryKeySchema
|
||||
workingRoot *doltdb.RootValue
|
||||
// toCommit and fromCommit are set via the
|
||||
// sql.IndexAddressable interface
|
||||
toCommit string
|
||||
fromCommit string
|
||||
requiredFilterErr error
|
||||
targetSchema schema.Schema
|
||||
}
|
||||
@@ -102,52 +104,61 @@ func (dt *CommitDiffTable) Collation() sql.CollationID {
|
||||
return sql.Collation_Default
|
||||
}
|
||||
|
||||
type SliceOfPartitionsItr struct {
|
||||
partitions []sql.Partition
|
||||
i int
|
||||
mu *sync.Mutex
|
||||
// GetIndexes implements sql.IndexAddressable
|
||||
func (dt *CommitDiffTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error) {
|
||||
return []sql.Index{index.DoltToFromCommitIndex(dt.name)}, nil
|
||||
}
|
||||
|
||||
func NewSliceOfPartitionsItr(partitions []sql.Partition) *SliceOfPartitionsItr {
|
||||
return &SliceOfPartitionsItr{
|
||||
partitions: partitions,
|
||||
mu: &sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
func (itr *SliceOfPartitionsItr) Next(*sql.Context) (sql.Partition, error) {
|
||||
itr.mu.Lock()
|
||||
defer itr.mu.Unlock()
|
||||
|
||||
if itr.i >= len(itr.partitions) {
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
next := itr.partitions[itr.i]
|
||||
itr.i++
|
||||
|
||||
return next, nil
|
||||
}
|
||||
|
||||
func (itr *SliceOfPartitionsItr) Close(*sql.Context) error {
|
||||
return nil
|
||||
// IndexedAccess implements sql.IndexAddressable
|
||||
func (dt *CommitDiffTable) IndexedAccess(lookup sql.IndexLookup) sql.IndexedTable {
|
||||
nt := *dt
|
||||
return &nt
|
||||
}
|
||||
|
||||
func (dt *CommitDiffTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error) {
|
||||
if dt.requiredFilterErr != nil {
|
||||
return nil, fmt.Errorf("error querying table %s: %w", dt.Name(), dt.requiredFilterErr)
|
||||
} else if dt.toCommitFilter == nil {
|
||||
return nil, fmt.Errorf("error querying table %s: %w", dt.Name(), ErrExactlyOneToCommit)
|
||||
} else if dt.fromCommitFilter == nil {
|
||||
return nil, fmt.Errorf("error querying table %s: %w", dt.Name(), ErrExactlyOneFromCommit)
|
||||
return nil, fmt.Errorf("error querying table %s: %w", dt.Name(), ErrExactlyOneToCommit)
|
||||
}
|
||||
|
||||
func (dt *CommitDiffTable) LookupPartitions(ctx *sql.Context, i sql.IndexLookup) (sql.PartitionIter, error) {
|
||||
if len(i.Ranges) != 1 || len(i.Ranges[0]) != 2 {
|
||||
return nil, ErrInvalidCommitDiffTableArgs
|
||||
}
|
||||
to := i.Ranges[0][0]
|
||||
from := i.Ranges[0][1]
|
||||
switch to.UpperBound.(type) {
|
||||
case sql.Above, sql.Below:
|
||||
default:
|
||||
return nil, ErrInvalidCommitDiffTableArgs
|
||||
}
|
||||
switch from.UpperBound.(type) {
|
||||
case sql.Above, sql.Below:
|
||||
default:
|
||||
return nil, ErrInvalidCommitDiffTableArgs
|
||||
}
|
||||
toCommit, _, err := to.Typ.Convert(sql.GetRangeCutKey(to.UpperBound))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ok bool
|
||||
dt.toCommit, ok = toCommit.(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("to_commit must be string, found %T", toCommit)
|
||||
}
|
||||
fromCommit, _, err := from.Typ.Convert(sql.GetRangeCutKey(from.UpperBound))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dt.fromCommit, ok = fromCommit.(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("from_commit must be string, found %T", fromCommit)
|
||||
}
|
||||
|
||||
toRoot, toHash, toDate, err := dt.rootValForFilter(ctx, dt.toCommitFilter)
|
||||
toRoot, toHash, toDate, err := dt.rootValForHash(ctx, dt.toCommit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fromRoot, fromHash, fromDate, err := dt.rootValForFilter(ctx, dt.fromCommitFilter)
|
||||
fromRoot, fromHash, fromDate, err := dt.rootValForHash(ctx, dt.fromCommit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -186,24 +197,38 @@ func (dt *CommitDiffTable) Partitions(ctx *sql.Context) (sql.PartitionIter, erro
|
||||
return NewSliceOfPartitionsItr([]sql.Partition{dp}), nil
|
||||
}
|
||||
|
||||
func (dt *CommitDiffTable) rootValForFilter(ctx *sql.Context, eqFilter *expression.Equals) (*doltdb.RootValue, string, *types.Timestamp, error) {
|
||||
gf, nonGF := eqFilter.Left(), eqFilter.Right()
|
||||
if _, ok := gf.(*expression.GetField); !ok {
|
||||
nonGF, gf = eqFilter.Left(), eqFilter.Right()
|
||||
type SliceOfPartitionsItr struct {
|
||||
partitions []sql.Partition
|
||||
i int
|
||||
mu *sync.Mutex
|
||||
}
|
||||
|
||||
func NewSliceOfPartitionsItr(partitions []sql.Partition) *SliceOfPartitionsItr {
|
||||
return &SliceOfPartitionsItr{
|
||||
partitions: partitions,
|
||||
mu: &sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
func (itr *SliceOfPartitionsItr) Next(*sql.Context) (sql.Partition, error) {
|
||||
itr.mu.Lock()
|
||||
defer itr.mu.Unlock()
|
||||
|
||||
if itr.i >= len(itr.partitions) {
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
val, err := nonGF.Eval(ctx, nil)
|
||||
next := itr.partitions[itr.i]
|
||||
itr.i++
|
||||
|
||||
if err != nil {
|
||||
return nil, "", nil, err
|
||||
}
|
||||
return next, nil
|
||||
}
|
||||
|
||||
hashStr, ok := val.(string)
|
||||
|
||||
if !ok {
|
||||
return nil, "", nil, fmt.Errorf("received '%v' when expecting commit hash string", val)
|
||||
}
|
||||
func (itr *SliceOfPartitionsItr) Close(*sql.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dt *CommitDiffTable) rootValForHash(ctx *sql.Context, hashStr string) (*doltdb.RootValue, string, *types.Timestamp, error) {
|
||||
var root *doltdb.RootValue
|
||||
var commitTime *types.Timestamp
|
||||
if strings.ToLower(hashStr) == "working" {
|
||||
@@ -240,68 +265,6 @@ func (dt *CommitDiffTable) rootValForFilter(ctx *sql.Context, eqFilter *expressi
|
||||
return root, hashStr, commitTime, nil
|
||||
}
|
||||
|
||||
// HandledFilters returns the list of filters that will be handled by the table itself
|
||||
func (dt *CommitDiffTable) HandledFilters(filters []sql.Expression) []sql.Expression {
|
||||
var commitFilters []sql.Expression
|
||||
for _, filter := range filters {
|
||||
eqFilter, isEquality := filter.(*expression.Equals)
|
||||
if !isEquality {
|
||||
continue
|
||||
}
|
||||
for _, e := range []sql.Expression{eqFilter.Left(), eqFilter.Right()} {
|
||||
val, ok := e.(*expression.GetField)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch strings.ToLower(val.Name()) {
|
||||
case toCommit, fromCommit:
|
||||
commitFilters = append(commitFilters, filter)
|
||||
}
|
||||
}
|
||||
}
|
||||
return commitFilters
|
||||
}
|
||||
|
||||
// Filters returns the list of filters that are applied to this table.
|
||||
func (dt *CommitDiffTable) Filters() []sql.Expression {
|
||||
if dt.toCommitFilter == nil && dt.fromCommitFilter == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return []sql.Expression{dt.toCommitFilter, dt.fromCommitFilter}
|
||||
}
|
||||
|
||||
// WithFilters returns a new sql.Table instance with the filters applied
|
||||
func (dt *CommitDiffTable) WithFilters(_ *sql.Context, filters []sql.Expression) sql.Table {
|
||||
for _, filter := range filters {
|
||||
eqFilter, isEquality := filter.(*expression.Equals)
|
||||
if eqFilter == nil || !isEquality {
|
||||
continue
|
||||
}
|
||||
for _, e := range []sql.Expression{eqFilter.Left(), eqFilter.Right()} {
|
||||
val, ok := e.(*expression.GetField)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch strings.ToLower(val.Name()) {
|
||||
case toCommit:
|
||||
if dt.toCommitFilter != nil {
|
||||
dt.requiredFilterErr = ErrExactlyOneToCommit
|
||||
return dt
|
||||
}
|
||||
dt.toCommitFilter = eqFilter
|
||||
case fromCommit:
|
||||
if dt.fromCommitFilter != nil {
|
||||
dt.requiredFilterErr = ErrExactlyOneFromCommit
|
||||
return dt
|
||||
}
|
||||
dt.fromCommitFilter = eqFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
return dt
|
||||
}
|
||||
|
||||
func (dt *CommitDiffTable) PartitionRows(ctx *sql.Context, part sql.Partition) (sql.RowIter, error) {
|
||||
dp := part.(DiffPartition)
|
||||
return dp.GetRowIter(ctx, dt.ddb, dt.joiner, sql.IndexLookup{})
|
||||
|
||||
@@ -51,7 +51,6 @@ const (
|
||||
)
|
||||
|
||||
var _ sql.Table = (*DiffTable)(nil)
|
||||
var _ sql.FilteredTable = (*DiffTable)(nil)
|
||||
var _ sql.IndexedTable = (*DiffTable)(nil)
|
||||
|
||||
type DiffTable struct {
|
||||
@@ -186,24 +185,6 @@ func (dt *DiffTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error) {
|
||||
|
||||
var commitMetaColumns = set.NewStrSet([]string{toCommit, fromCommit, toCommitDate, fromCommitDate})
|
||||
|
||||
// HandledFilters returns the list of filters that will be handled by the table itself
|
||||
func (dt *DiffTable) HandledFilters(filters []sql.Expression) []sql.Expression {
|
||||
dt.partitionFilters = FilterFilters(filters, ColumnPredicate(commitMetaColumns))
|
||||
return dt.partitionFilters
|
||||
}
|
||||
|
||||
// Filters returns the list of filters that are applied to this table.
|
||||
func (dt *DiffTable) Filters() []sql.Expression {
|
||||
return dt.partitionFilters
|
||||
}
|
||||
|
||||
// WithFilters returns a new sql.Table instance with the filters applied
|
||||
func (dt *DiffTable) WithFilters(_ *sql.Context, filters []sql.Expression) sql.Table {
|
||||
ret := *dt
|
||||
ret.partitionFilters = FilterFilters(filters, ColumnPredicate(commitMetaColumns))
|
||||
return &ret
|
||||
}
|
||||
|
||||
// CommitIsInScope returns true if a given commit hash is head or is
|
||||
// visible from the current head's ancestry graph.
|
||||
func (dt *DiffTable) CommitIsInScope(ctx context.Context, height uint64, h hash.Hash) (bool, error) {
|
||||
|
||||
@@ -40,8 +40,6 @@ var commitHistoryPartitionKey = []byte("commithistory")
|
||||
var commitHashCol = "commit_hash"
|
||||
var filterColumnNameSet = set.NewStrSet([]string{commitHashCol})
|
||||
|
||||
var _ sql.FilteredTable = (*UnscopedDiffTable)(nil)
|
||||
|
||||
// UnscopedDiffTable is a sql.Table implementation of a system table that shows which tables have
|
||||
// changed in each commit, across all branches.
|
||||
type UnscopedDiffTable struct {
|
||||
@@ -57,29 +55,6 @@ func NewUnscopedDiffTable(_ *sql.Context, dbName string, ddb *doltdb.DoltDB, hea
|
||||
return &UnscopedDiffTable{dbName: dbName, ddb: ddb, head: head}
|
||||
}
|
||||
|
||||
// Filters returns the list of filters that are applied to this table.
|
||||
func (dt *UnscopedDiffTable) Filters() []sql.Expression {
|
||||
return dt.partitionFilters
|
||||
}
|
||||
|
||||
// HandledFilters returns the list of filters that will be handled by the table itself
|
||||
func (dt *UnscopedDiffTable) HandledFilters(filters []sql.Expression) []sql.Expression {
|
||||
filters = append(filters, dt.partitionFilters...)
|
||||
dt.partitionFilters = FilterFilters(filters, ColumnPredicate(filterColumnNameSet))
|
||||
return dt.partitionFilters
|
||||
}
|
||||
|
||||
// WithFilters returns a new sql.Table instance with the filters applied
|
||||
func (dt *UnscopedDiffTable) WithFilters(_ *sql.Context, filters []sql.Expression) sql.Table {
|
||||
dt.partitionFilters = FilterFilters(filters, ColumnPredicate(filterColumnNameSet))
|
||||
commitCheck, err := commitFilterForDiffTableFilterExprs(dt.partitionFilters)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
dt.commitCheck = commitCheck
|
||||
return dt
|
||||
}
|
||||
|
||||
// Name is a sql.Table interface function which returns the name of the table which is defined by the constant
|
||||
// DiffTableName
|
||||
func (dt *UnscopedDiffTable) Name() string {
|
||||
|
||||
@@ -1706,7 +1706,7 @@ func TestColumnDiffSystemTable(t *testing.T) {
|
||||
}
|
||||
for _, test := range ColumnDiffSystemTableScriptTests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
enginetest.TestScriptPrepared(t, newDoltHarness(t), test)
|
||||
enginetest.TestScript(t, newDoltHarness(t), test)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4495,7 +4495,7 @@ var CommitDiffSystemTableScriptTests = []queries.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "SELECT * FROM DOLT_COMMIT_DIFF_t where to_commit=@Commit1;",
|
||||
ExpectedErrStr: "error querying table dolt_commit_diff_t: dolt_commit_diff_* tables must be filtered to a single 'from_commit'",
|
||||
ExpectedErrStr: dtables.ErrInvalidCommitDiffTableArgs.Error(),
|
||||
},
|
||||
{
|
||||
Query: "SELECT * FROM DOLT_COMMIT_DIFF_t where from_commit=@Commit1;",
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/set"
|
||||
"github.com/dolthub/dolt/go/store/datas"
|
||||
@@ -55,7 +54,6 @@ var (
|
||||
)
|
||||
|
||||
var _ sql.Table = (*HistoryTable)(nil)
|
||||
var _ sql.FilteredTable = (*HistoryTable)(nil)
|
||||
var _ sql.IndexAddressableTable = (*HistoryTable)(nil)
|
||||
var _ sql.IndexedTable = (*HistoryTable)(nil)
|
||||
|
||||
@@ -175,24 +173,6 @@ func historyTableSchema(tableName string, table *DoltTable) sql.Schema {
|
||||
return newSch
|
||||
}
|
||||
|
||||
// HandledFilters returns the list of filters that will be handled by the table itself
|
||||
func (ht *HistoryTable) HandledFilters(filters []sql.Expression) []sql.Expression {
|
||||
ht.commitFilters = dtables.FilterFilters(filters, dtables.ColumnPredicate(historyTableCommitMetaCols))
|
||||
return ht.commitFilters
|
||||
}
|
||||
|
||||
// Filters returns the list of filters that are applied to this table.
|
||||
func (ht *HistoryTable) Filters() []sql.Expression {
|
||||
return ht.commitFilters
|
||||
}
|
||||
|
||||
// WithFilters returns a new sql.Table instance with the filters applied. We handle filters on any commit columns.
|
||||
func (ht *HistoryTable) WithFilters(ctx *sql.Context, filters []sql.Expression) sql.Table {
|
||||
ret := *ht
|
||||
ret.commitFilters = dtables.FilterFilters(filters, dtables.ColumnPredicate(historyTableCommitMetaCols))
|
||||
return &ret
|
||||
}
|
||||
|
||||
func (ht *HistoryTable) filterIter(ctx *sql.Context, iter doltdb.CommitItr) (doltdb.CommitItr, error) {
|
||||
if len(ht.commitFilters) > 0 {
|
||||
r, err := ht.doltTable.db.GetRoot(ctx)
|
||||
|
||||
@@ -183,6 +183,20 @@ func DoltDiffIndexesFromTable(ctx context.Context, db, tbl string, t *doltdb.Tab
|
||||
return indexes, nil
|
||||
}
|
||||
|
||||
func DoltToFromCommitIndex(tbl string) sql.Index {
|
||||
return &doltIndex{
|
||||
id: "commits",
|
||||
tblName: doltdb.DoltCommitDiffTablePrefix + tbl,
|
||||
columns: []schema.Column{
|
||||
schema.NewColumn(ToCommitIndexId, schema.DiffCommitTag, types.StringKind, false),
|
||||
schema.NewColumn(FromCommitIndexId, schema.DiffCommitTag, types.StringKind, false),
|
||||
},
|
||||
unique: true,
|
||||
comment: "",
|
||||
order: sql.IndexOrderNone,
|
||||
constrainedToLookupExpression: false,
|
||||
}
|
||||
}
|
||||
func DoltCommitIndexes(tab string, db *doltdb.DoltDB, unique bool) (indexes []sql.Index, err error) {
|
||||
if !types.IsFormat_DOLT(db.Format()) {
|
||||
return nil, nil
|
||||
|
||||
@@ -126,7 +126,7 @@ func newPointPartitionIter(ctx *sql.Context, lookup sql.IndexLookup, idx *doltIn
|
||||
rng := lookup.Ranges[0]
|
||||
ns := idx.ns
|
||||
for j, expr := range rng {
|
||||
v, err := getRangeCutValue(expr.LowerBound, rng[j].Typ)
|
||||
v, err := getRangeCutValue(expr.LowerBound, expr.Typ)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -80,6 +80,10 @@ type TableSinkSuite struct {
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
func (suite2 *TableSinkSuite) SetS(suite suite.TestingSuite) {}
|
||||
|
||||
var _ suite.TestingSuite = (*TableSinkSuite)(nil)
|
||||
|
||||
func (suite *TableSinkSuite) SetT(t *testing.T) {
|
||||
suite.t = t
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ go 1.19
|
||||
|
||||
require (
|
||||
github.com/dolthub/dolt/go v0.40.4
|
||||
github.com/stretchr/testify v1.8.1
|
||||
github.com/stretchr/testify v1.8.2
|
||||
golang.org/x/sync v0.1.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
@@ -12,8 +12,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
|
||||
Reference in New Issue
Block a user