Skip to content

Commit

Permalink
Merge pull request #424 from CodeLieutenant/feat/disable-materialized…
Browse files Browse the repository at this point in the history
…-views

feature(materialized-views): add cli flags to disable materialized views
  • Loading branch information
dkropachev authored Sep 12, 2024
2 parents 7600ee9 + 91bd64d commit accfcf2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/gemini/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var (
minColumns int
datasetSize string
cqlFeatures string
useMaterializedViews bool
level string
maxRetriesMutate int
maxRetriesMutateSleep time.Duration
Expand Down Expand Up @@ -496,6 +497,7 @@ func init() {
rootCmd.Flags().IntVarP(&minColumns, "min-columns", "", 8, "Minimum number of generated columns")
rootCmd.Flags().StringVarP(&datasetSize, "dataset-size", "", "large", "Specify the type of dataset size to use, small|large")
rootCmd.Flags().StringVarP(&cqlFeatures, "cql-features", "", "basic", "Specify the type of cql features to use, basic|normal|all")
rootCmd.Flags().BoolVarP(&useMaterializedViews, "materialized-views", "", false, "Run gemini with materialized views support")
rootCmd.Flags().StringVarP(&level, "level", "", "info", "Specify the logging level, debug|info|warn|error|dpanic|panic|fatal")
rootCmd.Flags().IntVarP(&maxRetriesMutate, "max-mutation-retries", "", 2, "Maximum number of attempts to apply a mutation")
rootCmd.Flags().DurationVarP(
Expand Down
2 changes: 2 additions & 0 deletions cmd/gemini/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func createSchemaConfig(logger *zap.Logger) typedef.SchemaConfig {
UseLWT: defaultConfig.UseLWT,
CQLFeature: defaultConfig.CQLFeature,
AsyncObjectStabilizationAttempts: defaultConfig.AsyncObjectStabilizationAttempts,
UseMaterializedViews: defaultConfig.UseMaterializedViews,
AsyncObjectStabilizationDelay: defaultConfig.AsyncObjectStabilizationDelay,
}
default:
Expand Down Expand Up @@ -85,6 +86,7 @@ func createDefaultSchemaConfig(logger *zap.Logger) typedef.SchemaConfig {
UseCounters: useCounters,
UseLWT: useLWT,
CQLFeature: getCQLFeature(cqlFeatures),
UseMaterializedViews: useMaterializedViews,
AsyncObjectStabilizationAttempts: asyncObjectStabilizationAttempts,
AsyncObjectStabilizationDelay: asyncObjectStabilizationDelay,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/generators/statement_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func genTable(sc typedef.SchemaConfig, tableName string, r *rand.Rand) *typedef.
table.Indexes = indexes

var mvs []typedef.MaterializedView
if sc.CQLFeature > typedef.CQL_FEATURE_BASIC && len(clusteringKeys) > 0 && columns.ValidColumnsForPrimaryKey().Len() != 0 {
if sc.CQLFeature > typedef.CQL_FEATURE_BASIC && sc.UseMaterializedViews && len(clusteringKeys) > 0 && columns.ValidColumnsForPrimaryKey().Len() != 0 {
mvs = CreateMaterializedViews(columns, table.Name, partitionKeys, clusteringKeys, r)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/typedef/schemaconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SchemaConfig struct {
MinStringLength int
UseCounters bool
UseLWT bool
UseMaterializedViews bool
CQLFeature CQLFeature
AsyncObjectStabilizationAttempts int
AsyncObjectStabilizationDelay time.Duration
Expand Down

0 comments on commit accfcf2

Please sign in to comment.