Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix removing multi node support #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
50 changes: 20 additions & 30 deletions pkg/targets/timescaledb/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,36 +195,26 @@ func (d *dbCreator) createTableAndIndexes(dbBench *sql.DB, tableName string, fie
}

if d.opts.UseHypertable {
var creationCommand string = "create_hypertable"
var partitionsOption string = "replication_factor => NULL"

MustExec(dbBench, "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE")

// Replication factor determines whether we create a distributed hypertable
// or not. If it is unset or zero, then we will create a regular
// hypertable with no partitions.
//
// If replication factor is greater >= 1, we assume there are at least multiple
// data nodes. We currently use `create_hypertable` for both statements, the
// default behavior is to create a distributed hypertable if `replication_factor`
// is >= 1

// We assume a single partition hypertable. This provides an option to test
// partitioning on regular hypertables
if d.opts.NumberPartitions > 0 {
partitionsOption = fmt.Sprintf("partitioning_column => '%s'::name, number_partitions => %v::smallint", partitionColumn, d.opts.NumberPartitions)
}

if d.opts.ReplicationFactor > 0 {
// This gives us a future option of testing the impact of
// multi-node replication across data nodes
partitionsOption = fmt.Sprintf("partitioning_column => '%s'::name, replication_factor => %v::smallint", partitionColumn, d.opts.ReplicationFactor)
}

MustExec(dbBench,
fmt.Sprintf("SELECT %s('%s'::regclass, 'time'::name, %s, chunk_time_interval => %d, create_default_indexes=>FALSE)",
creationCommand, tableName, partitionsOption, d.opts.ChunkTime.Nanoseconds()/1000))
}
var creationCommand string = "create_hypertable"
var partitionsOption string = ""
MustExec(dbBench, "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE")
// Handle partitioning options if NumberPartitions is set
if d.opts.NumberPartitions > 0 {
partitionsOption = fmt.Sprintf("partitioning_column => '%s'::name, number_partitions => %v::smallint", partitionColumn, d.opts.NumberPartitions)
}

// Construct the query dynamically based on the options
query := fmt.Sprintf("SELECT %s('%s'::regclass, 'time'::name", creationCommand, tableName)

// Add partitionsOption if specified
if partitionsOption != "" {
query += fmt.Sprintf(", %s", partitionsOption)
}

// Add chunk_time_interval and create_default_indexes
query += fmt.Sprintf(", chunk_time_interval => %d, create_default_indexes=>FALSE)", d.opts.ChunkTime.Nanoseconds()/1000)
MustExec(dbBench, query)
}
}

func (d *dbCreator) getCreateIndexOnFieldCmds(hypertable, field, idxType string) []string {
Expand Down