Skip to content

Conversation

@erikjohnston
Copy link
Member

@erikjohnston erikjohnston commented May 14, 2025

As these should be background updates.

(foot-gun)

Spawning from #18439

@erikjohnston erikjohnston marked this pull request as ready for review May 14, 2025 15:17
@erikjohnston erikjohnston requested a review from a team as a code owner May 14, 2025 15:17
Copy link
Contributor

@MadLittleMods MadLittleMods left a comment

Choose a reason for hiding this comment

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

Assuming you've tried this out to ensure the matching actually works 👍

Thanks for making a lint to catch this mistake!

@erikjohnston
Copy link
Member Author

Assuming you've tried this out to ensure the matching actually works 👍

Yup, this run shows it checking a valid delta file, and this one shows it failing due to matching a CREATE UNIQUE index

Copy link
Contributor

@MadLittleMods MadLittleMods left a comment

Choose a reason for hiding this comment

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

Still some strange pre-existing logic in this file but as good as before with a new good feature 👍

@@ -0,0 +1 @@
Add lint to ensure we don't add a `CREATE/DROP INDEX` in a schema delta.
Copy link
Contributor

Choose a reason for hiding this comment

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

why would we ban DROP INDEX? Afaik that is instant?

Copy link
Member Author

Choose a reason for hiding this comment

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

It isn't instant for large tables, and takes out aggressive locks, which why there's a DROP INDEX CONCURRENTLY version

Copy link
Member Author

Choose a reason for hiding this comment

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

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.",
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

but you can write the index definition inline in the CREATE TABLE statement

lies, it seems you can't do this for indices. :<

Copy link
Member Author

@erikjohnston erikjohnston May 15, 2025

Choose a reason for hiding this comment

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

D'oh. Good catch. Have updated to allow index creation for tables we create in the same PR.

@erikjohnston erikjohnston requested a review from a team May 15, 2025 13:09

repo = git.Repo()
repo.remote().fetch()
repo.remote().fetch(refspec="develop")
Copy link
Contributor

Choose a reason for hiding this comment

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

Label this magic value

Suggested change
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?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was purely to speed things up, so that we only pull that one branch that we care about rather than all branches

@erikjohnston erikjohnston enabled auto-merge (squash) May 19, 2025 10:47
@erikjohnston erikjohnston merged commit fa4a00a into develop May 19, 2025
31 checks passed
@erikjohnston erikjohnston deleted the erikj/lint_schema_deltas branch May 19, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants