Skip to content

Commit

Permalink
sql/randgen: avoid invalid inverted indexes in CREATE TABLE
Browse files Browse the repository at this point in the history
Previously, the create table made via the randgen component
could create invalid CREATE TABLE statements where the last
columns of an inverted index were descending. This could
lead to unexpected failures in certain workloads, which
expected valid statements from this components. To address
this, this patch stops randgen from generating CREATE table
statements with invalid inverted indexes.

Release note: None
  • Loading branch information
fqazi committed Aug 8, 2022
1 parent 40d59b5 commit 16e5d55
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/sql/randgen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ func randIndexTableDefFromCols(
}
}

// Last column for inverted indexes must always be ascending.
if i == nCols-1 && def.Inverted {
elem.Direction = tree.Ascending
}

if !stopPrefix {
prefix = append(prefix, cols[i].Name)
}
Expand Down

0 comments on commit 16e5d55

Please sign in to comment.