Skip to content
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 numDmlAffectedRows to com.google.cloud.bigquery.TableResult #444

Closed
shrgupta28 opened this issue Jun 11, 2020 · 2 comments
Closed

Add numDmlAffectedRows to com.google.cloud.bigquery.TableResult #444

shrgupta28 opened this issue Jun 11, 2020 · 2 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/java-bigquery API. type: question Request for information or clarification. Not an issue.

Comments

@shrgupta28
Copy link

Hi Team,

I am using the below code to update the rows in my table using Java Cloud Bigquery.

String dmlQuery = String.format("update exploreTest.Student  set Stud_Name = \"Shruti11\", Stud_Class=\"II\" where Stud_Id = 300", datasetName, tableName);

			QueryJobConfiguration dmlQueryConfig =
					QueryJobConfiguration.newBuilder(dmlQuery).build();

			// Execute the query.
			TableResult result = bigquery.query(dmlQueryConfig);

I need to retrieve the number of rows affected/modified/updated. Request you to add the API for the same. Similar to the one we have in Bigquery V2 API as . queryResponse.getNumDmlAffectedRows()
Thanks.

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/java-bigquery API. label Jun 11, 2020
@pmakani pmakani self-assigned this Jun 12, 2020
@pmakani pmakani added the type: question Request for information or clarification. Not an issue. label Jun 12, 2020
@pmakani
Copy link
Contributor

pmakani commented Jun 12, 2020

@shrgupta28 I tested couple of times and getting num of affected rows , could you please try this ?

public void query() throws InterruptedException {
    String dmlQuery =
        String.format(
            "update exploreTest.Student  set Stud_Name = \"Shruti11\", Stud_Class=\"II\" where Stud_Id = 300");
    QueryJobConfiguration dmlQueryConfig = QueryJobConfiguration.newBuilder(dmlQuery).build();

    // Execute the query.
    Job job = bigQuery.create(JobInfo.of(dmlQueryConfig));
    job = job.waitFor();
    JobStatistics.QueryStatistics statistics = job.getStatistics();
    TableResult result = job.getQueryResults();
    long numDmlAffectedRows = statistics.getNumDmlAffectedRows();
    System.out.println(numDmlAffectedRows);
  }

@pmakani
Copy link
Contributor

pmakani commented Jun 12, 2020

Closing this issue through reference comments

@pmakani pmakani closed this as completed Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/java-bigquery API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants