csv

package
v6.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package csv implements an ephemeral Stroppy driver that writes generator output to CSV files on the local filesystem instead of a database. It exists to (a) benchmark pure generation throughput without database I/O, (b) produce reference output for cross-tool comparisons, and (c) feed downstream systems that bulk-load from delimited files (ClickHouse, DuckDB, PostgreSQL COPY, etc.).

Configuration is entirely URL-driven. The path component of the URL selects the output directory (defaults to the current working directory when absent) and the query string carries the small set of supported knobs: ?merge=true|false, ?separator=comma|tab, ?header=true|false.

The driver implements only the typed InsertRequest NATIVE path. Every other InsertMethod is rejected with ErrUnsupportedInsertMethod; runtime query execution is rejected with ErrCsvDriverNoQuery. DDL emitted by the drop_schema and create_schema workload steps is accepted and processed out-of-band: DROP clauses delete the workload's output directory for idempotent reruns, CREATE is a noop.

Index

Constants

This section is empty.

Variables

View Source
var ErrCsvDriverNoQuery = errors.New("csv: driver does not execute queries")

ErrCsvDriverNoQuery is returned when a non-DDL query reaches the CSV driver. CSV is write-only: it has no result set to produce and no transaction to run under. DDL emitted by the drop_schema and create_schema workload steps is recognized and handled out-of-band (DROP removes the workload's output directory; CREATE is a noop), so these steps remain runnable alongside load_data.

View Source
var ErrIncompleteLoad = errors.New("csv: output generation is incomplete")

ErrIncompleteLoad prevents final output from representing an incomplete CSV generation.

View Source
var ErrInvalidOption = errors.New("csv: invalid URL option")

ErrInvalidOption is the static parent error for any invalid URL query value. The concrete per-option message wraps it.

View Source
var (
	ErrUnsupportedInsertMethod = fmt.Errorf("csv: %w", driver.ErrInsertMethodNotSupported)
)

ErrUnsupportedInsertMethod is returned when an InsertRequest requests anything other than NATIVE. CSV is write-only: PLAIN_BULK and PLAIN_QUERY imply SQL-shaped emission, which the CSV driver does not synthesize. Matches the rejection pattern used by the other drivers.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver emits generator rows to CSV files. One Driver instance is scoped to one benchmark run; tables accumulate under a single output directory and are either merged or left as worker shards at Teardown.

func NewDriver

func NewDriver(_ context.Context, opts driver.Options) (*Driver, error)

NewDriver parses opts.Config.URL and returns a ready-to-use Driver. The output directory is created lazily (on first write) so Setup succeeds even when dir is a prefix that does not yet exist.

func (*Driver) Begin

Begin refuses to start a transaction. CSV writes have no rollback semantics and workloads that call tx.* are not supported.

func (*Driver) ClassifyError

func (*Driver) ClassifyError(err error) driver.ErrorFacts

func (*Driver) Insert

func (d *Driver) Insert(
	ctx context.Context,
	req *driver.InsertRequest,
) (_ *stats.Query, retErr error)

Insert runs a typed driver.InsertRequest through the CSV driver by draining each worker's gen.Cursor partition into a distinct shard file. NATIVE is the only method: CSV is write-only and does not synthesize SQL-shaped emission for PLAIN_BULK/PLAIN_QUERY.

func (*Driver) RunQuery

func (d *Driver) RunQuery(
	_ context.Context,
	sqlStr string,
	_ map[string]any,
) (*driver.QueryResult, error)

RunQuery accepts DDL (CREATE/DROP/TRUNCATE/ALTER/COMMENT) as a noop so workload drop_schema and create_schema steps stay valid with the CSV driver selected. DROP is treated as a directive to wipe the workload's output directory; everything else silently succeeds. Non-DDL queries return ErrCsvDriverNoQuery.

func (*Driver) Teardown

func (d *Driver) Teardown(ctx context.Context) error

Teardown finalizes the run: merges shards when configured, or emits a sidecar header when merge=false. Canceled finalization keeps source shards and does not publish a manifest or partial output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL