Check for CREATE/DROP INDEX in schema deltas#18440
Conversation
As these should be background updates.
MadLittleMods
left a comment
There was a problem hiding this comment.
Assuming you've tried this out to ensure the matching actually works 👍
Thanks for making a lint to catch this mistake!
| @@ -0,0 +1 @@ | |||
| Add lint to ensure we don't add a `CREATE/DROP INDEX` in a schema delta. | |||
There was a problem hiding this comment.
why would we ban DROP INDEX? Afaik that is instant?
There was a problem hiding this comment.
It isn't instant for large tables, and takes out aggressive locks, which why there's a DROP INDEX CONCURRENTLY version
There was a problem hiding this comment.
Though TBF it is rare for it to actually cause woe
| clause = match.group() | ||
|
|
||
| click.secho( | ||
| f"Found delta with index creation/deletion: '{clause}' in {delta_file}\nThese should be in background updates.", |
There was a problem hiding this comment.
maybe it'd be worth saying that, for new tables, it's fine to create the index right now, but you can write the index definition inline in the CREATE TABLE statement
There was a problem hiding this comment.
Good point! The CREATE INDEX syntax is useful but we would need to make the logic more robust to also make sure we see an associated CREATE TABLE in the same delta.
There was a problem hiding this comment.
but you can write the index definition inline in the CREATE TABLE statement
lies, it seems you can't do this for indices. :<
There was a problem hiding this comment.
D'oh. Good catch. Have updated to allow index creation for tables we create in the same PR.
|
|
||
| repo = git.Repo() | ||
| repo.remote().fetch() | ||
| repo.remote().fetch(refspec="develop") |
There was a problem hiding this comment.
Label this magic value
| repo.remote().fetch(refspec="develop") | |
| repo.remote().fetch(refspec=DEFAULT_BRANCH) |
Did this spawn from something you saw? I assume GitHub would give you the default branch anyway if you don't specify one?
There was a problem hiding this comment.
This was purely to speed things up, so that we only pull that one branch that we care about rather than all branches
Co-authored-by: Eric Eastwood <erice@element.io>
As these should be background updates.
(foot-gun)
Spawning from #18439