Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDC: Check for existing table in PG, SF, BQ #756

Closed
wants to merge 7 commits into from

Conversation

Amogh-Bharadwaj
Copy link
Contributor

@Amogh-Bharadwaj Amogh-Bharadwaj commented Dec 5, 2023

We now check if an existing destination table with the same name as the source table has the same schema as the source (ignoring _PEERDB columns we create for snowflake mirrors)
Fixes #256

@@ -738,20 +766,23 @@ func (c *SnowflakeConnector) SyncFlowCleanup(jobName string) error {
return nil
}

func (c *SnowflakeConnector) checkIfTableExists(schemaIdentifier string, tableIdentifier string) (bool, error) {
rows, err := c.database.QueryContext(c.ctx, checkIfTableExistsSQL, schemaIdentifier, tableIdentifier)
func (c *SnowflakeConnector) checkIfTableExists(schemaIdentifier string, tableIdentifier string) ([]protos.TableColumn, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
line is 128 characters (lll)

return nil, fmt.Errorf("destination column %s not found in source: ", existingField.Name)
}
if existingField.Name != desiredField.Name || existingField.Type != desiredField.Type {
return nil, fmt.Errorf("failed to setup normalized table due to incompatible columns: %s (destination) and %s (source)",
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
line is 140 characters (lll)

return nil, fmt.Errorf("destination column %s not found in source: ", existingField.Name)
}
if existingField.Name != desiredField.Name || existingField.Type != desiredField.Type {
return nil, fmt.Errorf("failed to setup normalized table due to incompatible columns: %s (destination) and %s (source)",
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
line is 140 characters (lll)

@Amogh-Bharadwaj
Copy link
Contributor Author

This feature is more complicated than originally pipelined due to newer features related to PeerDB columns, schema changes and so on. Closing with the aim of building this check on top of a newer PeerDB

@serprex serprex deleted the check-existing-table branch July 19, 2024 15:24
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.

Table matching needs to be uniform across streaming query and cdc
1 participant