-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add sample to schedule query with BQ DTS. #7703
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
Conversation
Oh, and I'm pretty sure I had to use user-based credentials with this thing, but I haven't tried with a service account since I added the |
This ensures the user (or service account) running the tests has owner permissions, which is required to run scheduled queries.
Wait for googleapis/synthtool#260 to merge. |
Unit test failure was related to #8147. I've reverted the generated code changes except for the noxfile update. |
# authorization code to a value from the URL: | ||
# https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?client_id=433065040935-hav5fqnc9p9cht3rqneus9115ias2kn1.apps.googleusercontent.com&scope=https://www.googleapis.com/auth/bigquery%20https://www.googleapis.com/auth/drive&redirect_uri=urn:ietf:wg:oauth:2.0:oob | ||
# | ||
# authorization_code = "_4/ABCD-EFGHIJKLMNOP-QRSTUVWXYZ" |
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.
Is this a live credential? Should we use something more abstract like AUTH_CODE_GOES_HERE?
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.
Is this a live credential?
No, that'd be pretty funny if it was (it's just the alphabet).
Should we use something more abstract like AUTH_CODE_GOES_HERE?
Maybe? I like when the example looks like the code I'm going to see, since it helps me with pattern matching, but I could be convinced that it's better to be clear that it's a placeholder.
"display_name": "Your Scheduled Query Name", | ||
"data_source_id": "scheduled_query", | ||
"params": { | ||
"query": "SELECT 1; -- Use standard SQL syntax.", |
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.
Let's show the injectable run params that DTS provides. The version of the sample I wrote did this:
SELECT
CURRENT_TIMESTAMP() as current_time,
@run_time as intended_run_time,
@run_date as intended_run_date,
17 as some_integer
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.
Done in 6b82d54.
|
||
@pytest.fixture(scope="module") | ||
def credentials(): | ||
creds, _ = google.auth.default(["https://www.googleapis.com/auth/cloud-platform"]) |
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.
Should we add some breadcrumbs about the permission setup for making the service account work here?
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.
The error messages actually showed me the commands to run this time, so that was good. Will the instructions change when it starts working how it's supposed to work?
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.
Done.
* Add semi-generated sample for BQ DTS. * Add authorization_code as parameter. * Give scheduled query example a shorter filename. * Add test for create scheduled query sample. * Create dataset in sample tests. This ensures the user (or service account) running the tests has owner permissions, which is required to run scheduled queries. * Add samples nox session.
Doesn't add tests. Because of the
authorization_code
parameter, I have no idea how to run automated tests.