Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
100515: sql: fix import test flake r=rharding6373 a=rharding6373

On import, generated stats have the name __import__, which may later be overridden as __auto__ when automatic stats collection occurs. This PR fixes a test flake which may encounter stats with these different names for tables.

Epic: None
Fixes: cockroachdb#99786

Release note: None

Co-authored-by: rharding6373 <[email protected]>
  • Loading branch information
craig[bot] and rharding6373 committed Apr 4, 2023
2 parents e1c8325 + 6813da1 commit 07c7d4b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/sql/importer/import_stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ func TestImportRowLimit(t *testing.T) {

t.Run("row limit multiple csv", func(t *testing.T) {
sqlDB.Exec(t, `CREATE DATABASE test; USE test`)
defer sqlDB.Exec(t, (`DROP DATABASE test`))
defer sqlDB.Exec(t, `DROP DATABASE test`)

data = "pear\navocado\nwatermelon\nsugar"
sqlDB.Exec(t, `CREATE TABLE t (s STRING)`)
Expand Down Expand Up @@ -6609,18 +6609,20 @@ func TestCreateStatsAfterImport(t *testing.T) {
sqlDB.Exec(t, "IMPORT PGDUMP ($1) WITH ignore_unsupported_statements", "nodelocal://1/cockroachdump/dump.sql")

// Verify that statistics have been created.
// Depending on timing, the statistics name may either be __auto__ or
// __import__, so we don't check the name in the results.
sqlDB.CheckQueryResultsRetry(t,
`SELECT statistics_name, column_names, row_count, distinct_count, null_count
`SELECT column_names, row_count, distinct_count, null_count
FROM [SHOW STATISTICS FOR TABLE t]`,
[][]string{
{"__auto__", "{i}", "2", "2", "0"},
{"__auto__", "{t}", "2", "2", "0"},
{"{i}", "2", "2", "0"},
{"{t}", "2", "2", "0"},
})
sqlDB.CheckQueryResultsRetry(t,
`SELECT statistics_name, column_names, row_count, distinct_count, null_count
`SELECT column_names, row_count, distinct_count, null_count
FROM [SHOW STATISTICS FOR TABLE a]`,
[][]string{
{"__auto__", "{i}", "1", "1", "0"},
{"{i}", "1", "1", "0"},
})
}

Expand Down

0 comments on commit 07c7d4b

Please sign in to comment.