-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunGetTable.java
More file actions
27 lines (25 loc) · 1.11 KB
/
runGetTable.java
File metadata and controls
27 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryException;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.Table;
import com.google.cloud.bigquery.TableId;
public class runGetTable {
public static void main(String[] args) {
//projectquickstart-323507.MY_DATASET_NAME.MY_TABLE_NAME2
String projectId = "projectquickstart-323507";
String dataSetName = "MY_DATASET_NAME";
String tableName = "MY_TABLE_NAME2";
getTableInfo(projectId,dataSetName,tableName);
}
public static void getTableInfo(String projectId,String dataSetName,String tableName){
try{
//initialize big query client
BigQuery bigQuery = BigQueryOptions.getDefaultInstance().getService();
TableId tableId = TableId.of(projectId,dataSetName,tableName);
Table table = bigQuery.getTable(tableId);
System.out.println("Table info:" + table.getDescription());
}catch (BigQueryException e){
System.out.println(" Table info not retrieved.\n"+e.toString());
}
}
}