Tabnine Logo
BigQuery.getTable
Code IndexAdd Tabnine to your IDE (free)

How to use
getTable
method
in
com.google.cloud.bigquery.BigQuery

Best Java code snippets using com.google.cloud.bigquery.BigQuery.getTable (Showing top 20 results out of 315)

origin: googleapis/google-cloud-java

/** Example of getting a table. */
// [TARGET getTable(String, String, TableOption...)]
// [VARIABLE "my_dataset_name"]
// [VARIABLE "my_table_name"]
public Table getTable(String datasetName, String tableName) {
 // [START ]
 Table table = bigquery.getTable(datasetName, tableName);
 // [END ]
 return table;
}
origin: googleapis/google-cloud-java

 @Override
 public void run(BigQuery bigquery, TableId tableId) {
  System.out.println("Table info: " + bigquery.getTable(tableId));
 }
}
origin: googleapis/google-cloud-java

/** Example of getting a table. */
// [TARGET getTable(TableId, TableOption...)]
// [VARIABLE "my_project_id"]
// [VARIABLE "my_dataset_name"]
// [VARIABLE "my_table_name"]
public Table getTableFromId(String projectId, String datasetName, String tableName) {
 // [START bigquery_get_table]
 TableId tableId = TableId.of(projectId, datasetName, tableName);
 Table table = bigquery.getTable(tableId);
 // [END bigquery_get_table]
 return table;
}
origin: googleapis/google-cloud-java

/** Example of updating a table by changing its expiration. */
// [TARGET update(TableInfo, TableOption...)]
// [VARIABLE "my_dataset_name"]
// [VARIABLE "my_table_name"]
public Table updateTableExpiration(String datasetName, String tableName) {
 // [START bigquery_update_table_expiration]
 Table beforeTable = bigquery.getTable(datasetName, tableName);
 // Set table to expire 5 days from now.
 long expirationMillis = DateTime.now().plusDays(5).getMillis();
 TableInfo tableInfo = beforeTable.toBuilder().setExpirationTime(expirationMillis).build();
 Table afterTable = bigquery.update(tableInfo);
 // [END bigquery_update_table_expiration]
 return afterTable;
}
origin: googleapis/google-cloud-java

/**
 * Returns the requested table in this dataset or {@code null} if not found.
 *
 * <p>Example of getting a table in the dataset.
 *
 * <pre>{@code
 * String tableName = “my_table”;
 * Table table = dataset.get(tableName);
 * }</pre>
 *
 * @param tableId user-defined id of the requested table
 * @param options table options
 * @throws BigQueryException upon failure
 */
public Table get(String tableId, TableOption... options) {
 return bigquery.getTable(TableId.of(getDatasetId().getDataset(), tableId), options);
}
origin: googleapis/google-cloud-java

/** Example of updating a table by changing its description. */
public Table updateTableDescription(String datasetName, String tableName, String newDescription) {
 // [START bigquery_update_table_description]
 // String datasetName = "my_dataset_name";
 // String tableName = "my_table_name";
 // String newDescription = "new_description";
 Table beforeTable = bigquery.getTable(datasetName, tableName);
 TableInfo tableInfo = beforeTable.toBuilder().setDescription(newDescription).build();
 Table afterTable = bigquery.update(tableInfo);
 // [END bigquery_update_table_description]
 return afterTable;
}
origin: googleapis/google-cloud-java

@Test
public void testGetNonExistingTable() {
 assertNull(bigquery.getTable(DATASET, "test_get_non_existing_table"));
}
origin: googleapis/google-cloud-java

@Test
public void testReloadNull() throws Exception {
 initializeExpectedTable(1);
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO.getTableId())).andReturn(null);
 replay(bigquery);
 initializeTable();
 assertNull(table.reload());
}
origin: googleapis/google-cloud-java

@Test
public void testExists_True() throws Exception {
 initializeExpectedTable(1);
 BigQuery.TableOption[] expectedOptions = {BigQuery.TableOption.fields()};
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO.getTableId(), expectedOptions)).andReturn(expectedTable);
 replay(bigquery);
 initializeTable();
 assertTrue(table.exists());
}
origin: googleapis/google-cloud-java

@Test
public void testExists_False() throws Exception {
 initializeExpectedTable(1);
 BigQuery.TableOption[] expectedOptions = {BigQuery.TableOption.fields()};
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO.getTableId(), expectedOptions)).andReturn(null);
 replay(bigquery);
 initializeTable();
 assertFalse(table.exists());
}
origin: googleapis/google-cloud-java

@Test
public void testGetNull() throws Exception {
 initializeExpectedDataset(1);
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO1.getTableId())).andReturn(null);
 replay(bigquery);
 initializeDataset();
 assertNull(dataset.get(TABLE_INFO1.getTableId().getTable()));
}
origin: googleapis/google-cloud-java

@Test
public void testGetTable() {
 EasyMock.expect(bigqueryRpcMock.getTable(PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
   .andReturn(TABLE_INFO_WITH_PROJECT.toPb());
 EasyMock.replay(bigqueryRpcMock);
 bigquery = options.getService();
 Table table = bigquery.getTable(DATASET, TABLE);
 assertEquals(new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PROJECT)), table);
}
origin: googleapis/google-cloud-java

@Test
public void testGetTableFromTableId() {
 EasyMock.expect(bigqueryRpcMock.getTable(PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
   .andReturn(TABLE_INFO_WITH_PROJECT.toPb());
 EasyMock.replay(bigqueryRpcMock);
 bigquery = options.getService();
 Table table = bigquery.getTable(TABLE_ID);
 assertEquals(new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PROJECT)), table);
}
origin: googleapis/google-cloud-java

@Test
public void testReload() throws Exception {
 initializeExpectedTable(4);
 TableInfo updatedInfo = TABLE_INFO.toBuilder().setDescription("Description").build();
 Table expectedTable =
   new Table(serviceMockReturnsOptions, new TableInfo.BuilderImpl(updatedInfo));
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO.getTableId())).andReturn(expectedTable);
 replay(bigquery);
 initializeTable();
 Table updatedTable = table.reload();
 compareTable(expectedTable, updatedTable);
}
origin: googleapis/google-cloud-java

@Test
public void testGet() throws Exception {
 initializeExpectedDataset(2);
 Table expectedTable =
   new Table(serviceMockReturnsOptions, new TableInfo.BuilderImpl(TABLE_INFO1));
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO1.getTableId())).andReturn(expectedTable);
 replay(bigquery);
 initializeDataset();
 Table table = dataset.get(TABLE_INFO1.getTableId().getTable());
 assertNotNull(table);
 assertEquals(expectedTable, table);
}
origin: googleapis/google-cloud-java

@Test
public void testGetTableFromTableIdWithProject() {
 TableInfo tableInfo = TABLE_INFO.setProjectId(OTHER_PROJECT);
 TableId tableId = TABLE_ID.setProjectId(OTHER_PROJECT);
 EasyMock.expect(bigqueryRpcMock.getTable(OTHER_PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
   .andReturn(tableInfo.toPb());
 EasyMock.replay(bigqueryRpcMock);
 BigQueryOptions bigQueryOptions =
   createBigQueryOptionsForProject(OTHER_PROJECT, rpcFactoryMock);
 bigquery = bigQueryOptions.getService();
 Table table = bigquery.getTable(tableId);
 assertEquals(new Table(bigquery, new TableInfo.BuilderImpl(tableInfo)), table);
}
origin: googleapis/google-cloud-java

@Test
public void testGetWithOptions() throws Exception {
 initializeExpectedDataset(2);
 Table expectedTable =
   new Table(serviceMockReturnsOptions, new TableInfo.BuilderImpl(TABLE_INFO1));
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO1.getTableId(), BigQuery.TableOption.fields()))
   .andReturn(expectedTable);
 replay(bigquery);
 initializeDataset();
 Table table = dataset.get(TABLE_INFO1.getTableId().getTable(), BigQuery.TableOption.fields());
 assertNotNull(table);
 assertEquals(expectedTable, table);
}
origin: googleapis/google-cloud-java

@Test
public void testReloadWithOptions() throws Exception {
 initializeExpectedTable(4);
 TableInfo updatedInfo = TABLE_INFO.toBuilder().setDescription("Description").build();
 Table expectedTable =
   new Table(serviceMockReturnsOptions, new TableInfo.BuilderImpl(updatedInfo));
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO.getTableId(), BigQuery.TableOption.fields()))
   .andReturn(expectedTable);
 replay(bigquery);
 initializeTable();
 Table updatedTable = table.reload(BigQuery.TableOption.fields());
 compareTable(expectedTable, updatedTable);
}
origin: googleapis/google-cloud-java

@Test
public void testGetTableWithSelectedFields() {
 Capture<Map<BigQueryRpc.Option, Object>> capturedOptions = Capture.newInstance();
 EasyMock.expect(
     bigqueryRpcMock.getTable(eq(PROJECT), eq(DATASET), eq(TABLE), capture(capturedOptions)))
   .andReturn(TABLE_INFO_WITH_PROJECT.toPb());
 EasyMock.replay(bigqueryRpcMock);
 bigquery = options.getService();
 Table table = bigquery.getTable(TABLE_ID, TABLE_OPTION_FIELDS);
 String selector = (String) capturedOptions.getValue().get(TABLE_OPTION_FIELDS.getRpcOption());
 assertTrue(selector.contains("tableReference"));
 assertTrue(selector.contains("schema"));
 assertTrue(selector.contains("etag"));
 assertEquals(31, selector.length());
 assertEquals(new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PROJECT)), table);
}
origin: googleapis/google-cloud-java

@Test
public void testGetTableFromTableIdWithoutProject() {
 TableInfo tableInfo = TABLE_INFO.setProjectId(PROJECT);
 TableId tableId = TableId.of("", TABLE_ID.getDataset(), TABLE_ID.getTable());
 EasyMock.expect(bigqueryRpcMock.getTable(PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
   .andReturn(tableInfo.toPb());
 EasyMock.replay(bigqueryRpcMock);
 BigQueryOptions bigQueryOptions = createBigQueryOptionsForProject(PROJECT, rpcFactoryMock);
 bigquery = bigQueryOptions.getService();
 Table table = bigquery.getTable(tableId);
 assertEquals(new Table(bigquery, new TableInfo.BuilderImpl(tableInfo)), table);
}
com.google.cloud.bigqueryBigQuerygetTable

Javadoc

Returns the requested table or null if not found.

Example of getting a table.

 
String projectId = "my_project_id";

Popular methods of BigQuery

  • create
    Creates a new table.
  • delete
    Deletes the requested dataset.
  • getDataset
    Returns the requested dataset or null if not found.
  • insertAll
    Sends an insert all request.
  • update
    Updates table information.
  • listTables
    Lists the tables in the dataset. This method returns partial information on each table: ( Table#tabl
  • query
    Runs the query associated with the request.
  • cancel
    Sends a job cancel request. This call will return immediately. The job status can then be checked us
  • getJob
    Returns the requested job or null if not found.
  • getQueryResults
    Returns results of the query associated with the provided job.
  • listDatasets
    Lists the project's datasets. This method returns partial information on each dataset: ( Dataset#dat
  • listTableData
    Lists the table's rows.Example of listing table rows, specifying the page size. String datasetName
  • listDatasets,
  • listTableData,
  • writer,
  • getOptions,
  • listJobs,
  • options

Popular in Java

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • getSystemService (Context)
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now