Skip to content

test: only create test tables if they do not already exist #101

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

Merged
merged 1 commit into from
Mar 28, 2021

Conversation

tswast
Copy link
Collaborator

@tswast tswast commented Mar 25, 2021

This should avoid race conditions when creating views from recently
(re)created tables.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #99 🦕

This should avoid race conditions when creating views from recently
(re)created tables.
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 25, 2021
@tswast tswast requested a review from shollyman March 25, 2021 17:02
Copy link

@shollyman shollyman left a comment

Choose a reason for hiding this comment

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

LGTM, though another refinement might be to put all the table generation in a SQL file or text blob, and run it as a set of CREATE TABLE ... IF NOT EXISTS ... AS SELECT statements. Then you can just gate on successful query or not.

Suppose it comes down to whether this kind of probe-or-build logic is more preferred to maintaining the SQL files, and it may be a wash if we end up centralizing sample tables.

@tswast
Copy link
Collaborator Author

tswast commented Mar 28, 2021

table generation in a SQL file or text blob, and run it as a set of CREATE TABLE ... IF NOT EXISTS ... AS SELECT statements

That's a good idea. Hopefully this method doesn't give us trouble, but if it does I can switch to that.

P.S. I actually did switch to DDL in the Ibis tests https://github.com/ibis-project/ibis/blob/master/ci/schema/bigquery.sql, though there we have the data in separate files at https://github.com/ibis-project/testing-data and don't actually create the tables as part of test setup. We expect a human to run a script to load the data once on the test project.

@tswast tswast merged commit b7c9d6f into googleapis:master Mar 28, 2021
@tswast tswast deleted the issue99-view-system-test branch March 28, 2021 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests.system.test_sqlalchemy_bigquery: many tests failed
2 participants