-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add table constraints support to Redshift #2435
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
Add table constraints support to Redshift #2435
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this can be tested, but mind checking?
Thanks!
| type=self.table_type, | ||
| table=self.table, | ||
| coldefs=coldefs, | ||
| table_constraints=table_constraints, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of the scope of this PR, but if you'd like it would be awesome to reduce the duplicated code here for where len == 2 and len == 3 for the creation of query. The only difference is the definition of coldefs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would agree with you that the whole Redshift contrib should be refactored. There would a lot of value to make it a little bit more DRY.
If I have more time in the upcoming weeks I'll take a jab at refactoring it so that it's a little bit saner! :)
c8161d6 to
831b8e0
Compare
While the table keys constraints (UNIQUE, PRIMARY, FOREIGN) aren't enforced by Redshift, it's still useful to be able to set that data. Given the situation that there is a monitoring task that manually checks if the table constraints are respected, it's useful to be able to set multiple primary keys on a given table. Based on the syntax of the CREATE commands of Redshift (see link down below) we think it's useful to add support to it. https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html
831b8e0 to
aaf3282
Compare
|
@dlstadther I've added specs like you've suggested. It seems though that there is a spec that randomly fails that is not related to my edit. What would you suggest the next step be? |
|
Now that I think more about this, maybe the constraint should be a tuple instead of a string. I'll think about it overnight and see where I stand on this! |
|
I reran the build and got a green build... weird |
|
I've decided to keep going on with the string instead of the tuple to follow the same behavior as |
|
Sorry for the delay here @cabouffard . Thanks for contributing! |
Description
Add the ability to add table constraint to Redshift tables.
Motivation and Context
While the table keys constraints (UNIQUE, PRIMARY, FOREIGN) aren't
enforced by Redshift, it's still useful to be able to set that data.
Given the situation that there is a monitoring task that manually checks
if the table constraints are respected, it's useful to be able to set
multiple primary keys on a given table.
Based on the syntax of the CREATE commands of Redshift (see link down
below) we think it's useful to add support to it.
https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html
Have you tested this? If so, how?
We've been using this feature for a few months now without problems.