Skip to content

Commit

Permalink
bulker: snowflake: don't load primary keys for empty tables
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Dec 4, 2024
1 parent 8b03619 commit 8281314
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bulkerlib/implementations/sql/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,22 +291,23 @@ func (s *Snowflake) GetTableSchema(ctx context.Context, namespace string, tableN
Statement: query,
})
}

if table.ColumnsCount() == 0 {
return table, nil
}

primaryKeyName, pkFields, err := s.getPrimaryKey(ctx, namespace, tableName)
if err != nil {
return nil, err
s.Errorf("failed to get primary key for table %s: %v", tableName, err)
//return nil, err
}

table.PKFields = pkFields
table.PrimaryKeyName = primaryKeyName

jitsuPrimaryKeyName := s.BuildConstraintName(table.Name)
if primaryKeyName != "" && strings.ToLower(primaryKeyName) != strings.ToLower(jitsuPrimaryKeyName) {
logging.Debugf("table: %s has a custom primary key with name: %s that isn't managed by Jitsu. Custom primary key will be used in rows deduplication and updates. primary_key_fields configuration provided in Jitsu config will be ignored.", table.Name, primaryKeyName)
s.Debugf("table: %s has a custom primary key with name: %s that isn't managed by Jitsu. Custom primary key will be used in rows deduplication and updates. primary_key_fields configuration provided in Jitsu config will be ignored.", table.Name, primaryKeyName)
}

return table, nil
Expand Down

0 comments on commit 8281314

Please sign in to comment.