Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ch/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,12 @@ func (w *Workloader) FinishPlanReplayerDump() error {
}

func (w *Workloader) Exec(sql string) error {
return nil
ctx := context.Background()
s := &chState{
TpcState: workload.NewTpcState(ctx, w.db),
}
defer s.Conn.Close()

_, err := s.Conn.ExecContext(ctx, sql)
return err
}
17 changes: 17 additions & 0 deletions cmd/go-tpc/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,23 @@ func executeWorkload(ctx context.Context, w workload.Workloader, threads int, ac
panic(fmt.Sprintf("a fatal occurred when preparing view data: %v", err))
}
}
// CH benchmark requires the revenue1 view for analytical queries.
// During normal prepare flow, this view is created in prepareView() method.
// However, when using CSV data ingestion, the prepare stage is skipped and
// the view won't exist. So we create it here when action is "run" to ensure
// the view is available regardless of how data was loaded.
if w.Name() == "ch" && action == "run" {
err := w.Exec(`create or replace view revenue1 (supplier_no, total_revenue) as (
select mod((s_w_id * s_i_id),10000) as supplier_no,
sum(ol_amount) as total_revenue
from order_line, stock
where ol_i_id = s_i_id and ol_supply_w_id = s_w_id
and ol_delivery_d >= '2007-01-02 00:00:00.000000'
group by mod((s_w_id * s_i_id),10000));`)
if err != nil {
panic(fmt.Sprintf("a fatal occurred when preparing view data: %v", err))
}
}
enabledDumpPlanReplayer := w.IsPlanReplayerDumpEnabled()
if enabledDumpPlanReplayer {
err := w.PreparePlanReplayerDump()
Expand Down