Skip to content

fix(clickpipes): change excluded columns type from list to set to avoid ordering issue#560

Open
tpanetti wants to merge 4 commits into
mainfrom
tp/clickpipes-cdc-excluded-column-ordering-fix
Open

fix(clickpipes): change excluded columns type from list to set to avoid ordering issue#560
tpanetti wants to merge 4 commits into
mainfrom
tp/clickpipes-cdc-excluded-column-ordering-fix

Conversation

@tpanetti
Copy link
Copy Markdown
Member

@tpanetti tpanetti commented Jun 1, 2026

Why

excluded_columns was modeled as a List rather than a Set. The backend returns excluded columns in an unguaranteed order, so a refresh could rewrite state in a different order than the config. The ModifyPlan "table mappings are immutable" guard compared them with order-sensitive List.Equal, so every subsequent plan then hard-failed with Cannot modify excluded_columns ... — even though the set of excluded columns was unchanged.

What

  • Converts excluded_columns from List to Set (Postgres, MySQL, BigQuery) so comparisons are order-insensitive. sorting_keys is intentionally left a List (ClickHouse sort-key order is semantically meaningful).
  • Updates API↔state sync to write excluded_columns as a types.Set, and brings the BigQuery branch to parity with Postgres/MySQL by preserving an empty set from prior state (avoids null↔empty churn on refresh).
  • Adds a ModifyPlan regression test: a reordered excluded_columns must not be flagged as a modification, while a real target_table change still is.

State migration

No StateUpgrader is needed (the earlier description's "state migration path" wording was inaccurate). A ListSet change is wire-compatible in terraform-plugin-framework: both serialize as JSON arrays and are disambiguated only by the schema type. When the stored state's schema version matches the current one, the framework's UpgradeResourceState passthrough re-decodes the existing array against the new Set type, so existing resources migrate automatically with a clean, no-op plan. No schema Version bump or upgrader is required.

Implements #558

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses ClickPipe plan/refresh instability caused by backend-returned excluded_columns ordering by modeling excluded_columns as an unordered Set, aligning provider semantics with the API behavior (Issue #558).

Changes:

  • Convert excluded_columns in ClickPipe table-mapping models and schema from List to Set to make comparisons order-insensitive.
  • Update state sync logic to write excluded_columns as a types.Set (instead of types.List) when reading from the API.
  • Add a regression test ensuring ModifyPlan does not reject reordered excluded_columns.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/resource/models/clickpipe_resource.go Switches table-mapping ExcludedColumns model fields and object types from List to Set.
pkg/resource/clickpipe.go Updates resource schema and API↔state sync to use Set for excluded_columns.
pkg/resource/clickpipe_test.go Updates existing test fixture state to represent excluded_columns as SetNull.
pkg/resource/clickpipe_bug_fixes_test.go Adds/updates regression coverage for Issue #558 and updates fixtures for Set-typed excluded_columns.
docs/resources/clickpipe.md Updates documentation to reflect excluded_columns as a Set of String.
Comments suppressed due to low confidence (1)

pkg/resource/clickpipe.go:1049

  • excluded_columns changed from List to Set in the schema, but this PR description mentions a state migration path and ClickPipeResource does not implement UpgradeState(...) (no state upgrader is present in this file). If Terraform/plugin-framework cannot automatically coerce the prior List state to the new Set type, existing states may fail to decode after upgrade. Either add an explicit state upgrader (List->Set) for excluded_columns in the ClickPipe resource or update the PR description to reflect the actual migration behavior.
										"excluded_columns": schema.SetAttribute{
											Description: "Columns to exclude from replication.",
											Optional:    true,
											ElementType: types.StringType,
										},

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/resource/clickpipe.go
@tpanetti tpanetti marked this pull request as ready for review June 1, 2026 23:47
@tpanetti tpanetti requested review from a team as code owners June 1, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants