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

BigQuery getting a query job with a statistics.query.timeline.completedInputs property fails #3015

Closed
tswast opened this issue Mar 9, 2018 · 0 comments
Assignees
Labels
api: bigquery Issues related to the BigQuery API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tswast
Copy link
Contributor

tswast commented Mar 9, 2018

Package: google-cloud-bigquery
Version: 0.38.0-beta

[ERROR] Tests run: 5, Failures: 0, Errors: 1, Skipped: 1, Time elapsed: 8.771 s <<< FAILURE! - in com.example.bigquery.QuerySampleIT
[ERROR] testPermanentTableQuery(com.example.bigquery.QuerySampleIT)  Time elapsed: 2.743 s  <<< ERROR!
com.google.cloud.bigquery.BigQueryException: java.lang.IllegalArgumentException: key completedInputs
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)
Caused by: java.lang.IllegalArgumentException: key completedInputs
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)
Caused by: java.lang.IllegalArgumentException: key completedInputs, field private com.google.api.services.bigquery.model.JobStatistics com.google.api.services.bigquery.model.Job.statistics
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)
Caused by: java.lang.IllegalArgumentException: key completedInputs, field private com.google.api.services.bigquery.model.JobStatistics2 com.google.api.services.bigquery.model.JobStatistics.query
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)
Caused by: java.lang.IllegalArgumentException: key completedInputs, field private java.util.List com.google.api.services.bigquery.model.JobStatistics2.timeline
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)
Caused by: java.lang.IllegalArgumentException: key completedInputs, field private java.util.List com.google.api.services.bigquery.model.JobStatistics2.timeline
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)
Caused by: java.lang.IllegalArgumentException: key completedInputs, field private java.lang.Integer com.google.api.services.bigquery.model.QueryTimelineSample.completedInputs
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)
Caused by: java.lang.IllegalArgumentException: number field formatted as a JSON string must use the @JsonString annotation
	at com.example.bigquery.QuerySampleIT.testPermanentTableQuery(QuerySampleIT.java:111)

[ERROR] Errors: 
[ERROR]   QuerySampleIT.testPermanentTableQuery:111 ? BigQuery java.lang.IllegalArgument...
[ERROR] Tests run: 11, Failures: 0, Errors: 1, Skipped: 1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:verify (default) on project bigquery-google-cloud-samples: There are test failures.

See: GoogleCloudPlatform/java-docs-samples#1055 (comment)

Code sample where this issue is seen:

  public static void runQueryPermanentTable(
      String queryString,
      String destinationDataset,
      String destinationTable,
      boolean allowLargeResults) throws TimeoutException, InterruptedException {
    QueryJobConfiguration queryConfig =
        QueryJobConfiguration.newBuilder(queryString)
            // Save the results of the query to a permanent table. See:
            // https://cloud.google.com/bigquery/docs/writing-results#permanent-table
            .setDestinationTable(TableId.of(destinationDataset, destinationTable))
            // Allow results larger than the maximum response size.
            // If true, a destination table must be set. See: 
            // https://cloud.google.com/bigquery/docs/writing-results#large-results
            .setAllowLargeResults(allowLargeResults)
            .build();

    runQuery(queryConfig);
  }

  public static void runQuery(QueryJobConfiguration queryConfig)
      throws TimeoutException, InterruptedException {
    BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();

    // Create a job ID so that we can safely retry.
    JobId jobId = JobId.of(UUID.randomUUID().toString());
    Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).setJobId(jobId).build());

    // Wait for the query to complete.
    queryJob = queryJob.waitFor();

    // Check for errors
    if (queryJob == null) {
      throw new RuntimeException("Job no longer exists");
    } else if (queryJob.getStatus().getError() != null) {
      // You can also look at queryJob.getStatus().getExecutionErrors() for all
      // errors, not just the latest one.
      throw new RuntimeException(queryJob.getStatus().getError().toString());
    }

    // Get the results.
    TableResult result = queryJob.getQueryResults();

    // Print all pages of the results.
    while (result != null) {
      for (List<FieldValue> row : result.iterateAll()) {
        for (FieldValue val : row) {
          System.out.printf("%s,", val.toString());
        }
        System.out.printf("\n");
      }

      result = result.getNextPage();
    }
  }

Code: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/af753bb7bfe3b72307ec42cab7cefe75af2b5bd2/bigquery/cloud-client/src/main/java/com/example/bigquery/QuerySample.java

Query used in test:

SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;
@tswast tswast added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: bigquery Issues related to the BigQuery API. labels Mar 9, 2018
pongad added a commit that referenced this issue Mar 9, 2018
Fixes #3015.
Looks like the previous version wasn't annotated properly or something.
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 BigQuery API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants