Skip to content

fix: Filter results of getTablesForSpec to top-level tables in CLI#5294

Merged
kodiakhq[bot] merged 1 commit intomainfrom
fix-hanging-bug
Dec 2, 2022
Merged

fix: Filter results of getTablesForSpec to top-level tables in CLI#5294
kodiakhq[bot] merged 1 commit intomainfrom
fix-hanging-bug

Conversation

@hermanschaaf
Copy link
Copy Markdown
Contributor

@hermanschaaf hermanschaaf commented Dec 2, 2022

This fixes a hanging bug in recent versions of the CLI and some destination plugins (e.g. BigQuery, Snowflake). The actual bug is in the GetTablesForSpec SDK function, which should not return a flattened list of tables, but this fix for the CLI means the CLI will work with any version of GetTablesForSpec (even versions with the bug).

I will follow up shortly with a fix for the SDK.

func topLevelTables(allTables, tables schema.Tables) schema.Tables {
var top schema.Tables
for _, t := range tables {
if allTables.GetTopLevel(t.Name) == nil {
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.

Why do it this way, rather than checking if t.Parent is nil?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that was what I tried initially. Then I realized that the object we get back from getTablesFromSpec is deserialized from JSON, so it loses all the pointers that were present in the original object. For this reason it also isn't simple to set the parent pointers first and then checking t.Parent for nil. I felt like this solution is the cleanest for now.

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.

We might need to reestablish those pointers/table references in a later release.

@hermanschaaf hermanschaaf added the automerge Automatically merge once required checks pass label Dec 2, 2022
@kodiakhq kodiakhq bot merged commit 768e0c5 into main Dec 2, 2022
@kodiakhq kodiakhq bot deleted the fix-hanging-bug branch December 2, 2022 17:11
kodiakhq bot pushed a commit that referenced this pull request Dec 2, 2022
🤖 I have created a release *beep* *boop*
---


## [2.0.23](cli-v2.0.22...cli-v2.0.23) (2022-12-02)


### Bug Fixes

* **deps:** Update module google.golang.org/grpc to v1.51.0 ([#5231](#5231)) ([2498d05](2498d05))
* Filter results of getTablesForSpec to top-level tables in CLI ([#5294](#5294)) ([768e0c5](768e0c5))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
kodiakhq bot pushed a commit to cloudquery/plugin-sdk that referenced this pull request Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants