assertEquals(500, exception.getCode()); assertEquals("message", exception.getMessage()); assertNull(exception.getReason()); assertNull(exception.getError()); assertTrue(exception.isRetryable()); assertEquals(502, exception.getCode()); assertEquals("message", exception.getMessage()); assertNull(exception.getReason()); assertNull(exception.getError()); assertTrue(exception.isRetryable()); assertEquals(503, exception.getCode()); assertEquals("message", exception.getMessage()); assertNull(exception.getReason()); assertNull(exception.getError()); assertTrue(exception.isRetryable()); assertEquals(504, exception.getCode()); assertEquals("message", exception.getMessage()); assertNull(exception.getReason()); assertNull(exception.getError()); assertTrue(exception.isRetryable()); assertEquals(400, exception.getCode()); assertEquals("message", exception.getMessage()); assertNull(exception.getReason()); assertNull(exception.getError()); assertFalse(exception.isRetryable());
private boolean isTableMissingSchema(BigQueryException exception) { // If a table is missing a schema, it will raise a BigQueryException that the input is invalid // For more information about BigQueryExceptions, see: https://cloud.google.com/bigquery/troubleshooting-errors return exception.getReason() != null && exception.getReason().equalsIgnoreCase("invalid"); }
private QueryResponse query(BigQuery bigquery, QueryRequest queryRequest, String projectId) { QueryResponse queryResponse = null; try { queryResponse = bigquery.query(queryRequest); } catch (BigQueryException exception) { if ("responseTooLarge".equals(exception.getReason())) { return queryWithLarge(bigquery, queryRequest, projectId); } } return loopQueryResponse(bigquery, queryResponse); }
private QueryResponse query(BigQuery bigquery, QueryRequest queryRequest, String projectId) { QueryResponse queryResponse = null; try { queryResponse = bigquery.query(queryRequest); } catch (BigQueryException exception) { if ("responseTooLarge".equals(exception.getReason())) { return queryWithLarge(bigquery, queryRequest, projectId); } } return loopQueryResponse(bigquery, queryResponse); }
/** * @param exception the {@link BigQueryException} to check. * @return true if this error is an error that can be fixed by retrying with a smaller batch * size, or false otherwise. */ private static boolean isBatchSizeError(BigQueryException exception) { if (exception.getCode() == BAD_REQUEST_CODE && exception.getError() == null && exception.getReason() == null) { /* * 400 with no error or reason represents a request that is more than 10MB. This is not * documented but is referenced slightly under "Error codes" here: * https://cloud.google.com/bigquery/quota-policy * (by decreasing the batch size we can eventually expect to end up with a request under 10MB) */ return true; } else if (exception.getCode() == BAD_REQUEST_CODE && INVALID_REASON.equals(exception.getReason())) { /* * this is the error that the documentation claims google will return if a request exceeds * 10MB. if this actually ever happens... * todo distinguish this from other invalids (like invalid table schema). */ return true; } return false; }