Skip to content

Commit

Permalink
Support setting update mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Sep 6, 2023
1 parent 856cf92 commit 58a857f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/targets/ceresdb/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type SpecificConfig struct {
PrimaryKeys string `yaml:"primaryKeys" mapstructure:"primaryKeys"`
PartitionKeys string `yaml:"partitionKeys" mapstructure:"partitionKeys"`
AccessMode string `yaml:"accessMode" mapstructure:"accessMode"`
UpdateMode string `yaml:"updateMode" mapstructure:"updateMode"`
}

func parseSpecificConfig(v *viper.Viper) (*SpecificConfig, error) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/targets/ceresdb/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ func (d *dbCreator) createTable(client ceresdb.Client, tableName string,
withTmpl := `with (
enable_ttl = 'false',
num_rows_per_row_group='%d',
storage_format = '%s'
storage_format = '%s',
update_mode='%s'
);`

// Make sql
sql := fmt.Sprintf(crTmpl, tableName, strings.Join(columnDefs, ","), d.config.PrimaryKeys) + "\n"
if d.config.PartitionKeys != "" {
sql = sql + fmt.Sprintf(partTmpl, d.config.PartitionKeys) + "\n"
}
sql = sql + fmt.Sprintf(withTmpl, d.config.RowGroupSize, d.config.StorageFormat)
sql = sql + fmt.Sprintf(withTmpl, d.config.RowGroupSize, d.config.StorageFormat, d.config.UpdateMode)

// Execute
_, err := client.SQLQuery(context.TODO(), ceresdb.SQLQueryRequest{
Expand Down
5 changes: 5 additions & 0 deletions pkg/targets/ceresdb/implemented_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func (vm vmTarget) TargetSpecificFlags(flagPrefix string, flagSet *pflag.FlagSet
"direct",
"Access mode of ceresdb client",
)
flagSet.String(
flagPrefix+"update-mode",
"OVERWRITE",
"Update mode when insert",
)
}

func (vm vmTarget) TargetName() string {
Expand Down

0 comments on commit 58a857f

Please sign in to comment.