Skip to content

fix: Make CQTypes to Schema and introduce versioning.#348

Closed
yevgenypats wants to merge 16 commits intomainfrom
fix/type_test
Closed

fix: Make CQTypes to Schema and introduce versioning.#348
yevgenypats wants to merge 16 commits intomainfrom
fix/type_test

Conversation

@yevgenypats
Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats commented Nov 4, 2022

This make the following changes:

  • moves cqtype package into schema because we need the original ValueType reside inside the same package as the types. Given I didn't want to update all the plugins I moved the types into schema and not the otherway around
  • introduces semantic versioning for sdk and protobuf. This starts from v2 (because in go v1 is the same as no version so not possible to have a /v1)
  • Streamlines testing for destination plugins
  • Introduce Transformer and ReverseTransformer for destination plugins. This way it is easy for the SDK to have round trip tests with those transformers and the Read capability.

@github-actions github-actions bot added the fix label Nov 4, 2022
@github-actions github-actions bot added fix and removed fix labels Nov 6, 2022
@github-actions github-actions bot added fix and removed fix labels Nov 7, 2022
@yevgenypats yevgenypats mentioned this pull request Nov 7, 2022
@yevgenypats yevgenypats changed the title fix: Make types backward compatible fix: Make CQTypes to Schema and introduce versioning. Nov 7, 2022
@github-actions github-actions bot added fix and removed fix labels Nov 7, 2022
Copy link
Copy Markdown
Contributor

@hermanschaaf hermanschaaf left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Only thing is that we should probably mark this as fix! so that the version gets bumped to the next major version?

Name: "dur_pointer_col",
Type: schema.TypeTimeInterval,
Resolver: `schema.PathResolver("DurPointerCol")`,
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing some context, but why are the duration column tests being removed?

// need to check for duration here, as Go time.Duration is int64
if v == reflect.TypeOf(time.Duration(0)) {
return schema.TypeTimeInterval, nil
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh I see it's also removed here. Could this break an existing plugin by any chance?

if err := json.Unmarshal(res[i]["type"], &t); err != nil {
return err
}
if t <= TypeInvalid || t >= TypeEnd {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting technique to check t >= TypeEnd, but I like it 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it's very C (MAX_TYPE would be the C counterpart)

Copy link
Copy Markdown
Member

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

What @hermanschaaf said 👍

yevgenypats added a commit that referenced this pull request Nov 7, 2022
This is a split of this PR
#348 so it will be easier
to review.

Also, Im going to push the move to v2 maybe another week as we dont
really have anything that requires protocol changes for now. even though
it is the right way to do it and will make the cli much easier including
the need to things like that -
cloudquery/cloudquery#3657 as it will be all
handles on protobuf and go versioning side.

This current PR just moves cqtypes to schema and removes enumerating all
types in different locations to make sure when we add a new type tests
will catch if a type is not added to the right place and or not
connected to `TypeValue`.

Also this removes `TimeInterval` which 1) wasn't used 2) it is incorrect
because it used `time.Duration` as `TimeInterval` but it's not a
TimeInterval it's just a duration which is uint64 so there no need for a
special type for that. In PostgreSQL TimeInterval is actually completely
different type that contains timezones and it is not go `time.Duration`
rpc GetSyncSummary(GetSyncSummary.Request) returns (GetSyncSummary.Response);
// Fetch resources
rpc Sync(Sync.Request) returns (stream Sync.Response);
// Sync2 is a new sync API that supports CQ Types. It is not backward compatible with Sync.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doc looks a bit outdated, should explain by itself not referring to older sync

@yevgenypats
Copy link
Copy Markdown
Contributor Author

Closing in favour of #369

@yevgenypats yevgenypats closed this Nov 7, 2022
kodiakhq bot pushed a commit that referenced this pull request Nov 8, 2022
Closes #348

Introduce testing suite for destination plugins as well as number of methods to including `transformers` and `reverseTransformers` to help testing suite be able to test "end-to-end".

This also adds more testing with a `memoryDB` plugin to test destination plugin and destination plugin testing suite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants