-
Notifications
You must be signed in to change notification settings - Fork 556
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 QueryJob#num_dml_affected_rows and DDL/DML docs #2530
Conversation
I would like to get @tswast's review on this. |
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.
LGTM, but I'd defer to @tswast.
@tswast Do you think we should add wrapper methods similar to |
In Python we return a job for the query helper (but then allow iterating over it for getting the results). Ideally one should be able to use the same helper to call DDL and DML queries, though it's tough when the helper returns "results". We suffered a similar problem in Java, where my solution was to special-case an "empty results" object for DDL queries. googleapis/google-cloud-java#3469 |
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.
Property LGTM. I think the docs to recommend the job method are good for DDL / DML, but ideally one should be able to call the regular query method if they don't care about the detailed results.
@tswast Good suggestion, I've been working today on adding DDL/DML response info to the array type returned by |
Add job_gapi to Data. Update QueryJob#data to conditionally return empty Data.
@tswast @blowmage PTAL at the most recent commit:
|
end | ||
|
||
def ddl? | ||
%w[CREATE_TABLE CREATE_TABLE_AS_SELECT DROP_TABLE CREATE_VIEW \ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
end | ||
|
||
def dml? | ||
%w[INSERT UPDATE DELETE].include? statement_type |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
end | ||
|
||
def dml? | ||
%w[INSERT UPDATE DELETE].include? statement_type |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -217,6 +217,15 @@ def statement_type | |||
@gapi.statistics.query.statement_type | |||
end | |||
|
|||
def ddl? | |||
%w[CREATE_TABLE CREATE_TABLE_AS_SELECT DROP_TABLE CREATE_VIEW \ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -490,15 +511,18 @@ def wait_until_done! | |||
# | |||
def data token: nil, max: nil, start: nil | |||
return nil unless done? | |||
|
|||
if ddl? || dml? |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@tswast I updated totalRows to be |
[closes #2141]