Skip to content

Commit

Permalink
Mapped forceGuaranteedRollup parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz-h2o committed Jan 22, 2024
1 parent e396c72 commit 4f2870c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions common_spec_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type TuningConfig struct {
MaxRowsPerSegment int `json:"maxRowsPerSegment,omitempty"`
MaxRowsInMemory int `json:"maxRowsInMemory,omitempty"`
IndexSpecForIntermediatePersists *IndexSpec `json:"indexSpecForIntermediatePersists,omitempty"`
ForceGuaranteedRollup bool `json:"forceGuaranteedRollup,omitempty"`
}

// Metric is a Druid aggregator that is applied at ingestion time.
Expand Down
8 changes: 8 additions & 0 deletions task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ func SetTaskGranularitySpec(segmentGranularity string, queryGranularity *QueryGr
}
}

// SetForceGuaranteedRollup sets guaranteed rollup setting for ingestion spec.
// https://druid.apache.org/docs/latest/ingestion/rollup#perfect-rollup-vs-best-effort-rollup
func SetForceGuaranteedRollup(rollup bool) TaskIngestionSpecOptions {
return func(spec *TaskIngestionSpec) {
spec.Spec.TuningConfig.ForceGuaranteedRollup = rollup
}
}

// NewTaskIngestionSpec returns a default TaskIngestionSpec and applies any options passed to it.
func NewTaskIngestionSpec(options ...TaskIngestionSpecOptions) *TaskIngestionSpec {
spec := defaultTaskIngestionSpec()
Expand Down
2 changes: 2 additions & 0 deletions task_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestTaskIngestionSpec(t *testing.T) {
SetTaskSchemaDiscovery(false),
SetTaskTimestampColumn("__time"),
SetTaskGranularitySpec("DAY", &QueryGranularitySpec{"none"}, true),
SetForceGuaranteedRollup(true),
},
expected: func() *TaskIngestionSpec {
out := NewTaskIngestionSpec()
Expand All @@ -41,6 +42,7 @@ func TestTaskIngestionSpec(t *testing.T) {
out.Spec.DataSchema.GranularitySpec.SegmentGranularity = "DAY"
out.Spec.DataSchema.GranularitySpec.QueryGranularity = &QueryGranularitySpec{"none"}
out.Spec.DataSchema.GranularitySpec.Rollup = true
out.Spec.TuningConfig.ForceGuaranteedRollup = true
return out
}(),
},
Expand Down

0 comments on commit 4f2870c

Please sign in to comment.