Skip to content

Conversation

@yevgenypats
Copy link
Contributor

No description provided.

This will make sure that single resources are validated at the sync
stage and wont be passed to desitnations so it wont fail batches
in any of CQ destinations.
@github-actions
Copy link

github-actions bot commented Jan 2, 2023

⏱️ Benchmark results

  • DefaultConcurrency-2 resources/s: 11,954
  • Glob-2 ns/op: 146.5
  • TablesWithChildrenDefaultConcurrency-2 resources/s: 29,816
  • BufferedScanner-2 ns/op: 10.09
  • LogReader-2 ns/op: 30.54

Comment on lines 104 to 105
// Validates various constraints. for exmaple
// does all primary keys has values
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Validates various constraints. for exmaple
// does all primary keys has values
// Validates various constraints. For example,
// checks that all primary keys have values.

if resolvedResource == nil {
return
}
tableMetrics := p.metrics.TableClient[table.Name][client.ID()]
Copy link
Member

@hermanschaaf hermanschaaf Jan 2, 2023

Choose a reason for hiding this comment

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

Maybe this lookup should happen inside the if below it, because that's the only place it's used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

Copy link
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.

Looks good, nothing blocking


// Validates various constraints. For example: Does all primary keys has values.
func (r *Resource) Validate() error {
for i, c := range r.Table.Columns {
Copy link
Member

@erezrokah erezrokah Jan 2, 2023

Choose a reason for hiding this comment

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

How about we don't return early and report in case multiple primary keys are missing instead of only returning the first error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Added.

yevgenypats and others added 3 commits January 2, 2023 15:43
Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
@kodiakhq kodiakhq bot merged commit 09f891a into main Jan 2, 2023
@kodiakhq kodiakhq bot deleted the feat/pk_validation branch January 2, 2023 13:52
erezrokah pushed a commit that referenced this pull request Jan 3, 2023
🤖 I have created a release *beep* *boop*
---


##
[1.17.0](v1.16.1...v1.17.0)
(2023-01-02)


### Features

* Add primary key validation
([#563](#563))
([09f891a](09f891a))


### Bug Fixes

* **testing:** Sort results before comparison in tests
([#561](#561))
([587715d](587715d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
@erezrokah
Copy link
Member

FYI, this validation caught an issue in our tests, see cloudquery/cloudquery@5fc8b1f and https://github.com/cloudquery/cloudquery/actions/runs/3828313454/jobs/6513763728#step:7:115
🎉

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.

4 participants