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

fix: prevent unnecessary diff for rematerialization_mode #176

Merged
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions client/meta/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ func DefaultDependencyHandling() *DependencyHandlingInput {
return &DependencyHandlingInput{SaveMode: &mode}
}

func DependencyHandlingSkipRematerialization() *DependencyHandlingInput {
saveMode := SaveModeUpdateDatasetAndDependenciesIgnoringAllErrors
rematMode := RematerializationModeSkiprematerialization
return &DependencyHandlingInput{SaveMode: &saveMode, RematerializationMode: &rematMode}
}

// SaveDataset creates and updates datasets
func (client *Client) SaveDataset(ctx context.Context, workspaceId string, input *DatasetInput, queryInput *MultiStageQueryInput, dependencyHandling *DependencyHandlingInput) (*Dataset, error) {
resp, err := saveDataset(ctx, client.Gql, workspaceId, *input, *queryInput, dependencyHandling)
Expand Down
20 changes: 7 additions & 13 deletions observe/resource_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const (
schemaDatasetDescriptionDescription = "Dataset description."
schemaDatasetIconDescription = "Icon image."
schemaDatasetOIDDescription = "The Observe ID for dataset."

rematerializationModeRematerialize = "rematerialize"
rematerializationModeSkipRematerialization = "skip_rematerialization"
)

func resourceDataset() *schema.Resource {
Expand Down Expand Up @@ -154,7 +151,6 @@ func resourceDataset() *schema.Resource {
"rematerialization_mode": {
Type: schema.TypeString,
Optional: true,
Default: "rematerialize",
ValidateDiagFunc: validateEnums(gql.AllRematerializationModes),
Description: descriptions.Get("dataset", "schema", "rematerialization_mode"),
},
Expand Down Expand Up @@ -365,14 +361,13 @@ func resourceDatasetCreate(ctx context.Context, data *schema.ResourceData, meta
}

dependencyHandling := gql.DefaultDependencyHandling()
switch data.Get("rematerialization_mode").(string) {
case rematerializationModeRematerialize:
case rematerializationModeSkipRematerialization:
dependencyHandling = gql.DependencyHandlingSkipRematerialization()
if mode, ok := data.GetOk("rematerialization_mode"); ok {
rematerializationMode := gql.RematerializationMode(toCamel(mode.(string)))
dependencyHandling.RematerializationMode = &rematerializationMode

diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: "Skipping rematerialization on a new dataset is a no-op",
Summary: "rematerialization_mode on a new dataset is a no-op",
})
}

Expand Down Expand Up @@ -421,10 +416,9 @@ func resourceDatasetUpdate(ctx context.Context, data *schema.ResourceData, meta
wsid, _ := oid.NewOID(data.Get("workspace").(string))

dependencyHandling := gql.DefaultDependencyHandling()
switch data.Get("rematerialization_mode").(string) {
case rematerializationModeRematerialize:
case rematerializationModeSkipRematerialization:
dependencyHandling = gql.DependencyHandlingSkipRematerialization()
if mode, ok := data.GetOk("rematerialization_mode"); ok {
rematerializationMode := gql.RematerializationMode(toCamel(mode.(string)))
dependencyHandling.RematerializationMode = &rematerializationMode
}

result, err := client.SaveDataset(ctx, wsid.Id, input, queryInput, dependencyHandling)
Expand Down
2 changes: 1 addition & 1 deletion observe/resource_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestAccObserveDatasetUpdate(t *testing.T) {
resource.TestCheckResourceAttr("observe_dataset.first", "stage.0.input", ""),
resource.TestCheckResourceAttr("observe_dataset.first", "stage.0.pipeline", ""),
resource.TestCheckResourceAttr("observe_dataset.first", "acceleration_disabled_source", "view"),
resource.TestCheckResourceAttr("observe_dataset.first", "rematerialization_mode", "rematerialize"),
resource.TestCheckNoResourceAttr("observe_dataset.first", "rematerialization_mode"),
),
},
{
Expand Down
Loading