From ad79d8fbee3f03ee479effb03217db3c4ebb0914 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Wed, 21 Feb 2024 16:50:29 -0800 Subject: [PATCH] [auto-bump] [no-release-notes] dependency by max-hoffman (#7525) * [ga-bump-dep] Bump dependency in Dolt by max-hoffman * [skip actions] [ga-update-correctness] SQL Correctness updated to 99.999933 * fix query diff test * include db in table schemas * comment on flake test --------- Co-authored-by: max-hoffman Co-authored-by: coffeegoddd --- .../sql-correctness/current_correctness.txt | 2 +- go/go.mod | 2 +- go/go.sum | 4 +- go/libraries/doltcore/schema/statistic.go | 48 +++++++-------- go/libraries/doltcore/sqle/database.go | 14 ++--- .../sqle/dolt_query_diff_table_function.go | 58 +++++++++++-------- .../doltcore/sqle/dtables/blame_view.go | 1 + .../doltcore/sqle/dtables/branches_table.go | 12 ++-- .../sqle/dtables/column_diff_table.go | 16 ++--- .../sqle/dtables/commit_ancestors_table.go | 6 +- .../sqle/dtables/commit_diff_table.go | 6 +- .../doltcore/sqle/dtables/commits_table.go | 10 ++-- .../doltcore/sqle/dtables/diff_table.go | 4 +- .../doltcore/sqle/dtables/log_table.go | 10 ++-- .../sqle/dtables/merge_status_table.go | 10 ++-- .../sqle/dtables/schema_conflicts_table.go | 10 ++-- .../doltcore/sqle/dtables/statistics_table.go | 4 +- .../dtables/table_of_tables_in_conflict.go | 4 +- .../sqle/dtables/unscoped_diff_table.go | 16 ++--- .../sqle/enginetest/dolt_engine_test.go | 7 +++ go/libraries/doltcore/sqle/tables.go | 2 +- 21 files changed, 135 insertions(+), 111 deletions(-) diff --git a/.github/scripts/sql-correctness/current_correctness.txt b/.github/scripts/sql-correctness/current_correctness.txt index 0dafa9235c..8fe1a17330 100644 --- a/.github/scripts/sql-correctness/current_correctness.txt +++ b/.github/scripts/sql-correctness/current_correctness.txt @@ -1 +1 @@ -99.999848 +99.999933 diff --git a/go/go.mod b/go/go.mod index 335dc5d83c..f7a0a68f95 100644 --- a/go/go.mod +++ b/go/go.mod @@ -57,7 +57,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.17.1-0.20240218094724-404b39ebd64c + github.com/dolthub/go-mysql-server v0.17.1-0.20240221220516-968fb4d31772 github.com/dolthub/swiss v0.1.0 github.com/goccy/go-json v0.10.2 github.com/google/go-github/v57 v57.0.0 diff --git a/go/go.sum b/go/go.sum index 53f6c87e6e..57b808630f 100644 --- a/go/go.sum +++ b/go/go.sum @@ -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-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.17.1-0.20240218094724-404b39ebd64c h1:Wyizg+08lhUrHRbgF6w8kb4BesaL4ZgzDCEaBvM0G9s= -github.com/dolthub/go-mysql-server v0.17.1-0.20240218094724-404b39ebd64c/go.mod h1:282SPNGdGzoUa1GfBr/kKNMzMDSn9+eKIUPvYxlxIdg= +github.com/dolthub/go-mysql-server v0.17.1-0.20240221220516-968fb4d31772 h1:FekPkGD6KzSj7tM3f37mTW5Ai+82hC38R/13okI0Qeg= +github.com/dolthub/go-mysql-server v0.17.1-0.20240221220516-968fb4d31772/go.mod h1:282SPNGdGzoUa1GfBr/kKNMzMDSn9+eKIUPvYxlxIdg= 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.2-0.20240201003050-392940944c15 h1:sfTETOpsrNJPDn2KydiCtDgVu6Xopq8k3JP8PjFT22s= diff --git a/go/libraries/doltcore/schema/statistic.go b/go/libraries/doltcore/schema/statistic.go index 21cf5e27d2..4fdc0f24da 100644 --- a/go/libraries/doltcore/schema/statistic.go +++ b/go/libraries/doltcore/schema/statistic.go @@ -68,29 +68,31 @@ const ( StatsMcvCountsTag ) -var StatsTableSqlSchema = sql.PrimaryKeySchema{ - Schema: sql.Schema{ - &sql.Column{Name: StatsDbColName, Type: types.Text, PrimaryKey: true}, - &sql.Column{Name: StatsTableColName, Type: types.Text, PrimaryKey: true}, - &sql.Column{Name: StatsIndexColName, Type: types.Text, PrimaryKey: true}, - &sql.Column{Name: StatsPositionColName, Type: types.Int64, PrimaryKey: true}, - &sql.Column{Name: StatsVersionColName, Type: types.Int64}, - &sql.Column{Name: StatsCommitHashColName, Type: types.Text}, - &sql.Column{Name: StatsRowCountColName, Type: types.Int64}, - &sql.Column{Name: StatsDistinctCountColName, Type: types.Int64}, - &sql.Column{Name: StatsNullCountColName, Type: types.Int64}, - &sql.Column{Name: StatsColumnsColName, Type: types.Text}, - &sql.Column{Name: StatsTypesColName, Type: types.Text}, - &sql.Column{Name: StatsUpperBoundColName, Type: types.Text}, - &sql.Column{Name: StatsUpperBoundCntColName, Type: types.Int64}, - &sql.Column{Name: StatsCreatedAtColName, Type: types.Datetime}, - &sql.Column{Name: StatsMcv1ColName, Type: types.Text}, - &sql.Column{Name: StatsMcv2ColName, Type: types.Text}, - &sql.Column{Name: StatsMcv3ColName, Type: types.Text}, - &sql.Column{Name: StatsMcv4ColName, Type: types.Text}, - &sql.Column{Name: StatsMcvCountsColName, Type: types.Text}, - }, - PkOrdinals: []int{0, 1}, +func StatsTableSqlSchema(dbName string) sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: sql.Schema{ + &sql.Column{Name: StatsDbColName, Type: types.Text, PrimaryKey: true, DatabaseSource: dbName}, + &sql.Column{Name: StatsTableColName, Type: types.Text, PrimaryKey: true, DatabaseSource: dbName}, + &sql.Column{Name: StatsIndexColName, Type: types.Text, PrimaryKey: true, DatabaseSource: dbName}, + &sql.Column{Name: StatsPositionColName, Type: types.Int64, PrimaryKey: true, DatabaseSource: dbName}, + &sql.Column{Name: StatsVersionColName, Type: types.Int64, DatabaseSource: dbName}, + &sql.Column{Name: StatsCommitHashColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsRowCountColName, Type: types.Int64, DatabaseSource: dbName}, + &sql.Column{Name: StatsDistinctCountColName, Type: types.Int64, DatabaseSource: dbName}, + &sql.Column{Name: StatsNullCountColName, Type: types.Int64, DatabaseSource: dbName}, + &sql.Column{Name: StatsColumnsColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsTypesColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsUpperBoundColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsUpperBoundCntColName, Type: types.Int64, DatabaseSource: dbName}, + &sql.Column{Name: StatsCreatedAtColName, Type: types.Datetime, DatabaseSource: dbName}, + &sql.Column{Name: StatsMcv1ColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsMcv2ColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsMcv3ColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsMcv4ColName, Type: types.Text, DatabaseSource: dbName}, + &sql.Column{Name: StatsMcvCountsColName, Type: types.Text, DatabaseSource: dbName}, + }, + PkOrdinals: []int{0, 1}, + } } var StatsTableDoltSchema = StatsTableDoltSchemaGen() diff --git a/go/libraries/doltcore/sqle/database.go b/go/libraries/doltcore/sqle/database.go index 0b4aa29d03..c02b51f530 100644 --- a/go/libraries/doltcore/sqle/database.go +++ b/go/libraries/doltcore/sqle/database.go @@ -313,7 +313,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds } tableName := tblName[len(doltdb.DoltDiffTablePrefix):] - dt, err := dtables.NewDiffTable(ctx, tableName, db.ddb, root, head) + dt, err := dtables.NewDiffTable(ctx, db.Name(), tableName, db.ddb, root, head) if err != nil { return nil, false, err } @@ -321,7 +321,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds case strings.HasPrefix(lwrName, doltdb.DoltCommitDiffTablePrefix): suffix := tblName[len(doltdb.DoltCommitDiffTablePrefix):] - dt, err := dtables.NewCommitDiffTable(ctx, suffix, db.ddb, root) + dt, err := dtables.NewCommitDiffTable(ctx, db.Name(), suffix, db.ddb, root) if err != nil { return nil, false, err } @@ -382,7 +382,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds } } - dt, found = dtables.NewLogTable(ctx, db.RevisionQualifiedName(), db.ddb, head), true + dt, found = dtables.NewLogTable(ctx, db.Name(), db.ddb, head), true case doltdb.DiffTableName: if head == nil { var err error @@ -392,7 +392,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds } } - dt, found = dtables.NewUnscopedDiffTable(ctx, db.RevisionQualifiedName(), db.ddb, head), true + dt, found = dtables.NewUnscopedDiffTable(ctx, db.Name(), db.ddb, head), true case doltdb.ColumnDiffTableName: if head == nil { var err error @@ -402,7 +402,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds } } - dt, found = dtables.NewColumnDiffTable(ctx, db.RevisionQualifiedName(), db.ddb, head), true + dt, found = dtables.NewColumnDiffTable(ctx, db.Name(), db.ddb, head), true case doltdb.TableOfTablesInConflictName: dt, found = dtables.NewTableOfTablesInConflict(ctx, db.RevisionQualifiedName(), db.ddb), true case doltdb.TableOfTablesWithViolationsName: @@ -416,9 +416,9 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds case doltdb.RemotesTableName: dt, found = dtables.NewRemotesTable(ctx, db.ddb), true case doltdb.CommitsTableName: - dt, found = dtables.NewCommitsTable(ctx, db.RevisionQualifiedName(), db.ddb), true + dt, found = dtables.NewCommitsTable(ctx, db.Name(), db.ddb), true case doltdb.CommitAncestorsTableName: - dt, found = dtables.NewCommitAncestorsTable(ctx, db.RevisionQualifiedName(), db.ddb), true + dt, found = dtables.NewCommitAncestorsTable(ctx, db.Name(), db.ddb), true case doltdb.StatusTableName: sess := dsess.DSessFromSess(ctx.Session) adapter := dsess.NewSessionStateAdapter( diff --git a/go/libraries/doltcore/sqle/dolt_query_diff_table_function.go b/go/libraries/doltcore/sqle/dolt_query_diff_table_function.go index 64e1adb45f..b286754b37 100644 --- a/go/libraries/doltcore/sqle/dolt_query_diff_table_function.go +++ b/go/libraries/doltcore/sqle/dolt_query_diff_table_function.go @@ -199,35 +199,47 @@ func (tf *QueryDiffTableFunction) compareRows(pkOrds []int, row1, row2 sql.Row) // RowIter implements the sql.Node interface // TODO: actually implement a row iterator func (tf *QueryDiffTableFunction) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { + if !tf.schema1.Equals(tf.schema2) { + // todo: schema is currently an unreliable source of primary key columns + return tf.keylessRowIter() + } + return tf.pkRowIter() +} + +// keylessRowIter uses the entire row for difference comparison +func (tf *QueryDiffTableFunction) keylessRowIter() (sql.RowIter, error) { var results []sql.Row var newRow sql.Row - if !tf.schema1.Equals(tf.schema2) { - nilRow1, nilRow2 := make(sql.Row, len(tf.schema1)), make(sql.Row, len(tf.schema2)) - for { - row, err := tf.rowIter1.Next(tf.ctx) - if err == io.EOF { - break - } - if err != nil { - return nil, err - } - newRow = append(append(row, nilRow2...), "deleted") - results = append(results, newRow) + nilRow1, nilRow2 := make(sql.Row, len(tf.schema1)), make(sql.Row, len(tf.schema2)) + for { + row, err := tf.rowIter1.Next(tf.ctx) + if err == io.EOF { + break } - for { - row, err := tf.rowIter2.Next(tf.ctx) - if err == io.EOF { - break - } - if err != nil { - return nil, err - } - newRow = append(append(nilRow1, row...), "added") - results = append(results, newRow) + if err != nil { + return nil, err } - return sql.RowsToRowIter(results...), nil + newRow = append(append(row, nilRow2...), "deleted") + results = append(results, newRow) } + for { + row, err := tf.rowIter2.Next(tf.ctx) + if err == io.EOF { + break + } + if err != nil { + return nil, err + } + newRow = append(append(nilRow1, row...), "added") + results = append(results, newRow) + } + return sql.RowsToRowIter(results...), nil +} +// pkRowIter uses primary keys to do an efficient row comparison +func (tf *QueryDiffTableFunction) pkRowIter() (sql.RowIter, error) { + var results []sql.Row + var newRow sql.Row row1, err1 := tf.rowIter1.Next(tf.ctx) row2, err2 := tf.rowIter2.Next(tf.ctx) var pkOrds []int diff --git a/go/libraries/doltcore/sqle/dtables/blame_view.go b/go/libraries/doltcore/sqle/dtables/blame_view.go index 56794a59f2..00a4040631 100644 --- a/go/libraries/doltcore/sqle/dtables/blame_view.go +++ b/go/libraries/doltcore/sqle/dtables/blame_view.go @@ -28,6 +28,7 @@ import ( var errUnblameableTable = errors.New("unable to generate blame view for table without primary key") const ( + // todo: force /*+ JOIN_ORDER(sd,ld) */ for testing consistency viewExpressionTemplate = ` WITH sorted_diffs_by_pk AS (SELECT diff --git a/go/libraries/doltcore/sqle/dtables/branches_table.go b/go/libraries/doltcore/sqle/dtables/branches_table.go index a8b4a3f4d5..371345af39 100644 --- a/go/libraries/doltcore/sqle/dtables/branches_table.go +++ b/go/libraries/doltcore/sqle/dtables/branches_table.go @@ -92,12 +92,12 @@ func (bt *BranchesTable) Schema() sql.Schema { } columns := []*sql.Column{ - {Name: "name", Type: types.Text, Source: tableName, PrimaryKey: true, Nullable: false}, - {Name: "hash", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: false}, - {Name: "latest_committer", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true}, - {Name: "latest_committer_email", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true}, - {Name: "latest_commit_date", Type: types.Datetime, Source: tableName, PrimaryKey: false, Nullable: true}, - {Name: "latest_commit_message", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true}, + {Name: "name", Type: types.Text, Source: tableName, PrimaryKey: true, Nullable: false, DatabaseSource: bt.db.Name()}, + {Name: "hash", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: false, DatabaseSource: bt.db.Name()}, + {Name: "latest_committer", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: bt.db.Name()}, + {Name: "latest_committer_email", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: bt.db.Name()}, + {Name: "latest_commit_date", Type: types.Datetime, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: bt.db.Name()}, + {Name: "latest_commit_message", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: bt.db.Name()}, } if !bt.remote { columns = append(columns, &sql.Column{Name: "remote", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true}) diff --git a/go/libraries/doltcore/sqle/dtables/column_diff_table.go b/go/libraries/doltcore/sqle/dtables/column_diff_table.go index 29a5f69fa7..2d8e29be47 100644 --- a/go/libraries/doltcore/sqle/dtables/column_diff_table.go +++ b/go/libraries/doltcore/sqle/dtables/column_diff_table.go @@ -85,14 +85,14 @@ func (dt *ColumnDiffTable) String() string { // Schema is a sql.Table interface function that returns the sql.Schema for this system table. func (dt *ColumnDiffTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: true}, - {Name: "table_name", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: true}, - {Name: "column_name", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: true}, - {Name: "committer", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false}, - {Name: "email", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false}, - {Name: "date", Type: types.Datetime, Source: doltdb.ColumnDiffTableName, PrimaryKey: false}, - {Name: "message", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false}, - {Name: "diff_type", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "table_name", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "column_name", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "committer", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "email", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "date", Type: types.Datetime, Source: doltdb.ColumnDiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "message", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "diff_type", Type: types.Text, Source: doltdb.ColumnDiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, } } diff --git a/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go b/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go index 22201568ef..af604ad2ca 100644 --- a/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go +++ b/go/libraries/doltcore/sqle/dtables/commit_ancestors_table.go @@ -69,9 +69,9 @@ func (dt *CommitAncestorsTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the commit_ancestors system table. func (dt *CommitAncestorsTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: types.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, - {Name: "parent_hash", Type: types.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, - {Name: "parent_index", Type: types.Int32, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "parent_hash", Type: types.Text, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "parent_index", Type: types.Int32, Source: doltdb.CommitAncestorsTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, } } diff --git a/go/libraries/doltcore/sqle/dtables/commit_diff_table.go b/go/libraries/doltcore/sqle/dtables/commit_diff_table.go index aaed885bb4..580672f0d8 100644 --- a/go/libraries/doltcore/sqle/dtables/commit_diff_table.go +++ b/go/libraries/doltcore/sqle/dtables/commit_diff_table.go @@ -39,6 +39,7 @@ var ErrInvalidCommitDiffTableArgs = errors.New("commit_diff_ requires one type CommitDiffTable struct { name string + dbName string ddb *doltdb.DoltDB joiner *rowconv.Joiner sqlSch sql.PrimaryKeySchema @@ -55,7 +56,7 @@ var _ sql.Table = (*CommitDiffTable)(nil) var _ sql.IndexAddressable = (*CommitDiffTable)(nil) var _ sql.StatisticsTable = (*CommitDiffTable)(nil) -func NewCommitDiffTable(ctx *sql.Context, tblName string, ddb *doltdb.DoltDB, root *doltdb.RootValue) (sql.Table, error) { +func NewCommitDiffTable(ctx *sql.Context, dbName, tblName string, ddb *doltdb.DoltDB, root *doltdb.RootValue) (sql.Table, error) { diffTblName := doltdb.DoltCommitDiffTablePrefix + tblName table, _, ok, err := root.GetTableInsensitive(ctx, tblName) @@ -76,12 +77,13 @@ func NewCommitDiffTable(ctx *sql.Context, tblName string, ddb *doltdb.DoltDB, ro return nil, err } - sqlSch, err := sqlutil.FromDoltSchema("", diffTblName, diffTableSchema) + sqlSch, err := sqlutil.FromDoltSchema(dbName, diffTblName, diffTableSchema) if err != nil { return nil, err } return &CommitDiffTable{ + dbName: dbName, name: tblName, ddb: ddb, workingRoot: root, diff --git a/go/libraries/doltcore/sqle/dtables/commits_table.go b/go/libraries/doltcore/sqle/dtables/commits_table.go index d000929862..f5c9a60f59 100644 --- a/go/libraries/doltcore/sqle/dtables/commits_table.go +++ b/go/libraries/doltcore/sqle/dtables/commits_table.go @@ -72,11 +72,11 @@ func (dt *CommitsTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the commits system table. func (dt *CommitsTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: true}, - {Name: "committer", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, - {Name: "email", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, - {Name: "date", Type: types.Datetime, Source: doltdb.CommitsTableName, PrimaryKey: false}, - {Name: "message", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "committer", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "email", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "date", Type: types.Datetime, Source: doltdb.CommitsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "message", Type: types.Text, Source: doltdb.CommitsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, } } diff --git a/go/libraries/doltcore/sqle/dtables/diff_table.go b/go/libraries/doltcore/sqle/dtables/diff_table.go index 13e0a16678..6c0f7fd299 100644 --- a/go/libraries/doltcore/sqle/dtables/diff_table.go +++ b/go/libraries/doltcore/sqle/dtables/diff_table.go @@ -87,7 +87,7 @@ var PrimaryKeyChangeWarning = "cannot render full diff between commits %s and %s const PrimaryKeyChangeWarningCode int = 1105 // Since this is our own custom warning we'll use 1105, the code for an unknown error -func NewDiffTable(ctx *sql.Context, tblName string, ddb *doltdb.DoltDB, root *doltdb.RootValue, head *doltdb.Commit) (sql.Table, error) { +func NewDiffTable(ctx *sql.Context, dbName, tblName string, ddb *doltdb.DoltDB, root *doltdb.RootValue, head *doltdb.Commit) (sql.Table, error) { diffTblName := doltdb.DoltDiffTablePrefix + tblName table, tblName, ok, err := root.GetTableInsensitive(ctx, tblName) @@ -107,7 +107,7 @@ func NewDiffTable(ctx *sql.Context, tblName string, ddb *doltdb.DoltDB, root *do return nil, err } - sqlSch, err := sqlutil.FromDoltSchema("", diffTblName, diffTableSchema) + sqlSch, err := sqlutil.FromDoltSchema(dbName, diffTblName, diffTableSchema) if err != nil { return nil, err } diff --git a/go/libraries/doltcore/sqle/dtables/log_table.go b/go/libraries/doltcore/sqle/dtables/log_table.go index a17b6ffacd..01be17ad4e 100644 --- a/go/libraries/doltcore/sqle/dtables/log_table.go +++ b/go/libraries/doltcore/sqle/dtables/log_table.go @@ -88,11 +88,11 @@ func (dt *LogTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the log system table. func (dt *LogTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: true}, - {Name: "committer", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false}, - {Name: "email", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false}, - {Name: "date", Type: types.Datetime, Source: doltdb.LogTableName, PrimaryKey: false}, - {Name: "message", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "committer", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "email", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "date", Type: types.Datetime, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "message", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, } } diff --git a/go/libraries/doltcore/sqle/dtables/merge_status_table.go b/go/libraries/doltcore/sqle/dtables/merge_status_table.go index 327917016f..a8e78fa128 100644 --- a/go/libraries/doltcore/sqle/dtables/merge_status_table.go +++ b/go/libraries/doltcore/sqle/dtables/merge_status_table.go @@ -44,11 +44,11 @@ func (s MergeStatusTable) String() string { func (s MergeStatusTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "is_merging", Type: types.Boolean, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: false}, - {Name: "source", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "source_commit", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "target", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, - {Name: "unmerged_tables", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true}, + {Name: "is_merging", Type: types.Boolean, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: false, DatabaseSource: s.dbName}, + {Name: "source", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true, DatabaseSource: s.dbName}, + {Name: "source_commit", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true, DatabaseSource: s.dbName}, + {Name: "target", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true, DatabaseSource: s.dbName}, + {Name: "unmerged_tables", Type: types.Text, Source: doltdb.MergeStatusTableName, PrimaryKey: false, Nullable: true, DatabaseSource: s.dbName}, } } diff --git a/go/libraries/doltcore/sqle/dtables/schema_conflicts_table.go b/go/libraries/doltcore/sqle/dtables/schema_conflicts_table.go index e5f75ada04..1fbd490b2c 100644 --- a/go/libraries/doltcore/sqle/dtables/schema_conflicts_table.go +++ b/go/libraries/doltcore/sqle/dtables/schema_conflicts_table.go @@ -58,11 +58,11 @@ func (dt *SchemaConflictsTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the log system table. func (dt *SchemaConflictsTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "table_name", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: true}, - {Name: "base_schema", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false}, - {Name: "our_schema", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false}, - {Name: "their_schema", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false}, - {Name: "description", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false}, + {Name: "table_name", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "base_schema", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "our_schema", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "their_schema", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "description", Type: types.Text, Source: doltdb.SchemaConflictsTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, } } diff --git a/go/libraries/doltcore/sqle/dtables/statistics_table.go b/go/libraries/doltcore/sqle/dtables/statistics_table.go index c2ef939a3f..dbe399baa6 100644 --- a/go/libraries/doltcore/sqle/dtables/statistics_table.go +++ b/go/libraries/doltcore/sqle/dtables/statistics_table.go @@ -49,7 +49,7 @@ func NewStatisticsTable(_ *sql.Context, dbName string, ddb *doltdb.DoltDB) sql.T // DataLength implements sql.StatisticsTable func (st *StatisticsTable) DataLength(ctx *sql.Context) (uint64, error) { - numBytesPerRow := schema.SchemaAvgLength(schema.StatsTableSqlSchema.Schema) + numBytesPerRow := schema.SchemaAvgLength(schema.StatsTableSqlSchema(st.dbName).Schema) numRows, _, err := st.RowCount(ctx) if err != nil { return 0, err @@ -84,7 +84,7 @@ func (st *StatisticsTable) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the log system table. func (st *StatisticsTable) Schema() sql.Schema { - return schema.StatsTableSqlSchema.Schema + return schema.StatsTableSqlSchema(st.dbName).Schema } // Collation implements the sql.Table interface. diff --git a/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go b/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go index 27dc7484bf..3512cc1bbb 100644 --- a/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go +++ b/go/libraries/doltcore/sqle/dtables/table_of_tables_in_conflict.go @@ -52,8 +52,8 @@ func (dt *TableOfTablesInConflict) String() string { // Schema is a sql.Table interface function that gets the sql.Schema of the log system table. func (dt *TableOfTablesInConflict) Schema() sql.Schema { return []*sql.Column{ - {Name: "table", Type: types.Text, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: true}, - {Name: "num_conflicts", Type: types.Uint64, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: false}, + {Name: "table", Type: types.Text, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "num_conflicts", Type: types.Uint64, Source: doltdb.TableOfTablesInConflictName, PrimaryKey: false, DatabaseSource: dt.dbName}, } } diff --git a/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go b/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go index bb0cd556a5..5e3fb7856f 100644 --- a/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go +++ b/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go @@ -90,14 +90,14 @@ func (dt *UnscopedDiffTable) String() string { // Schema is a sql.Table interface function that returns the sql.Schema for this system table. func (dt *UnscopedDiffTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: true}, - {Name: "table_name", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: true}, - {Name: "committer", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "email", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "date", Type: types.Datetime, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "message", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "data_change", Type: types.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false}, - {Name: "schema_change", Type: types.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "table_name", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "committer", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "email", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "date", Type: types.Datetime, Source: doltdb.DiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "message", Type: types.Text, Source: doltdb.DiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "data_change", Type: types.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "schema_change", Type: types.Boolean, Source: doltdb.DiffTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, } } diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go index ae87227cc5..54a992daf4 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go @@ -2399,6 +2399,13 @@ func TestSystemTableIndexes(t *testing.T) { for i, c := range []string{"inner", "lookup", "hash", "merge"} { e.EngineAnalyzer().Coster = biasedCosters[i] for _, tt := range stt.queries { + if tt.query == "select count(*) from dolt_blame_xy" && c == "inner" { + // todo we either need join hints to work inside the blame view + // and force the window relation to be primary, or we need the + // blame view's timestamp columns to be specific enough to not + // overlap during testing. + t.Skip("the blame table is unstable as secondary table in join with exchange node") + } t.Run(fmt.Sprintf("%s(%s): %s", stt.name, c, tt.query), func(t *testing.T) { if tt.skip { t.Skip() diff --git a/go/libraries/doltcore/sqle/tables.go b/go/libraries/doltcore/sqle/tables.go index fff93b3201..f93f344043 100644 --- a/go/libraries/doltcore/sqle/tables.go +++ b/go/libraries/doltcore/sqle/tables.go @@ -145,7 +145,7 @@ func (t *DoltTable) LockedToRoot(ctx *sql.Context, root *doltdb.RootValue) (sql. return }) - sqlSch, err := sqlutil.FromDoltSchema("", t.tableName, sch) + sqlSch, err := sqlutil.FromDoltSchema(t.db.Name(), t.tableName, sch) if err != nil { return nil, err }