Skip to content

Commit dc4c69e

Browse files
fix
Signed-off-by: Lloyd-Pottiger <[email protected]>
1 parent f22811f commit dc4c69e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tpch/ddl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ func (w *Workloader) dropTables(ctx context.Context) error {
158158

159159
func (w *Workloader) createInvertedIndexes(ctx context.Context) error {
160160
indexes := map[string]string{
161-
"idx_l_receiptdate": "ALTER TABLE lineitem ADD COLUMNAR INDEX idx_l_receiptdate (l_receiptdate) USING INVERTED",
162-
"idx_l_shipdate": "ALTER TABLE lineitem ADD COLUMNAR INDEX idx_l_shipdate (l_shipdate) USING INVERTED",
163-
"idx_o_orderdate": "ALTER TABLE orders ADD COLUMNAR INDEX idx_o_orderdate (o_orderdate) USING INVERTED",
161+
"idx_l_receiptdate": "CREATE COLUMNAR INDEX IF NOT EXISTS idx_l_receiptdate ON lineitem (l_receiptdate) USING INVERTED",
162+
"idx_l_shipdate": "CREATE COLUMNAR INDEX IF NOT EXISTS idx_l_shipdate ON lineitem (l_shipdate) USING INVERTED",
163+
"idx_o_orderdate": "CREATE COLUMNAR INDEX IF NOT EXISTS idx_o_orderdate ON orders (o_orderdate) USING INVERTED",
164164
}
165165
s := w.getState(ctx)
166166
for name, stmt := range indexes {

tpch/workload.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ func (w *Workloader) CheckPrepare(ctx context.Context, threadID int) error {
212212
func (w *Workloader) Run(ctx context.Context, threadID int) error {
213213
s := w.getState(ctx)
214214
defer w.updateState(ctx)
215+
216+
// Create inverted index if needed.
217+
if w.cfg.AddInvertedIndex {
218+
if err := w.createInvertedIndexes(ctx); err != nil {
219+
return err
220+
}
221+
}
222+
215223
if err := s.Conn.PingContext(ctx); err != nil {
216224
if err := s.RefreshConn(ctx); err != nil {
217225
return err

0 commit comments

Comments
 (0)