private void onTableGet(Table table) throws IOException { when(mockClient.tables()).thenReturn(mockTables); when(mockTables.get(anyString(), anyString(), anyString())).thenReturn(mockTablesGet); when(mockTablesGet.execute()).thenReturn(table); }
private void verifyTableGet() throws IOException { verify(mockClient).tables(); verify(mockTables).get("project", "dataset", "table"); verify(mockTablesGet, atLeastOnce()).execute(); }
boolean found = true; try { bigquery.tables().get(exporterConfig.getBigqueryProjectId(), exporterConfig.getBigqueryDatasetId(), kind).execute();
@Override public Table getTable( String projectId, String datasetId, String tableId, Map<Option, ?> options) { try { return bigquery .tables() .get(projectId, datasetId, tableId) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return null; } throw serviceException; } }
/** * Returns true if the table exists, or false if not. */ public boolean tableExists(TableReference tableRef) throws IOException { try { Table fetchedTable = service.tables().get( tableRef.getProjectId(), tableRef.getDatasetId(), tableRef.getTableId()).execute(); logger.atFine().log( "Successfully fetched table '%s' for tableRef '%s'", fetchedTable, tableRef); return true; } catch (IOException ioe) { if (errorExtractor.itemNotFound(ioe)) { return false; } else { // Unhandled exceptions should just propagate up. throw ioe; } } }
@Override public Table getTable(String datasetId, String tableId, Map<Option, ?> options) { try { return bigquery.tables() .get(this.options.projectId(), datasetId, tableId) .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.code() == HTTP_NOT_FOUND) { return null; } throw serviceException; } }
@Override public Table getTable(String datasetId, String tableId, Map<Option, ?> options) { try { return bigquery.tables() .get(this.options.projectId(), datasetId, tableId) .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.code() == HTTP_NOT_FOUND) { return null; } throw serviceException; } }
private TableSchema getSchema(Bigquery bq) { try { return bq.tables() .get( pipelineOptions.getProject(), pipelineOptions.getTargetDataset(), table.getTableReference().getTableId()) .execute() .getSchema(); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Gets the specified table resource by table ID. This method does not return the data in the * table, it only returns the table resource, which describes the structure of this table. * * @param tableRef The BigQuery table reference. * @return The table resource, which describes the structure of this table. * @throws IOException */ public Table getTable(TableReference tableRef) throws IOException { Bigquery.Tables.Get getTablesReply = service.tables().get( tableRef.getProjectId(), tableRef.getDatasetId(), tableRef.getTableId()); return getTablesReply.execute(); }
@Override public Table getTable( String projectId, String datasetId, String tableId, Map<Option, ?> options) { try { return bigquery .tables() .get(projectId, datasetId, tableId) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return null; } throw serviceException; } }