cloudquery/plugin-sdk

feat(codegen): `codegen` should fail if column names clash (after adding extra columns, naturally)

Closed this issue · 2 comments

type A struct {
    Abc string
}

If we feed struct A to codegen it will naturally produce column named abc.
If we add an extra column with the same name and forget to add filed Abc to be skipped, we end up with duplicate names in the resulting resource table.

Now, this will result in cloudquery CLI failing on the sync/init part as it checks for the data integrity then. There will be something like panic: found duplicate columns in source plugin: test: duplicate column abc in table test_resource.

The proposal is to add this check to codegen, too, so that such issues are highlighted during the development.

disq commented

While this is a quality-of-life feature, it's easy to miss an unintended column overwrite if this feature is enabled implicitly.

Is there an example where we want this? Maybe, the data has column N that we overwrite as some meta-info, and we want to preserve the column info, too?
In this case, at least let's fail the generation if there are clashing column names, so that the developer will have to address this issue right away?