use of com.google.cloud.bigquery.TableId in project presto by prestodb.
the class BigQueryClient method getTable.
public TableInfo getTable(TableId tableId) {
TableId bigQueryTableId = tableIds.get(tableId);
Table table = bigQuery.getTable(bigQueryTableId != null ? bigQueryTableId : tableId);
if (table != null) {
tableIds.putIfAbsent(tableId, table.getTableId());
datasetIds.putIfAbsent(toDatasetId(tableId), toDatasetId(table.getTableId()));
}
return table;
}
use of com.google.cloud.bigquery.TableId in project presto by prestodb.
the class BigQueryTableHandle method from.
public static BigQueryTableHandle from(TableInfo tableInfo) {
TableId tableId = tableInfo.getTableId();
String type = tableInfo.getDefinition().getType().toString();
return new BigQueryTableHandle(tableId.getProject(), tableId.getDataset(), tableId.getTable(), type, TupleDomain.none(), Optional.empty(), OptionalLong.empty());
}
use of com.google.cloud.bigquery.TableId in project components by Talend.
the class BigQueryDatasetRuntimeTestIT method initDatasetAndTable.
@BeforeClass
public static void initDatasetAndTable() throws IOException {
BigQuery bigquery = BigQueryConnection.createClient(createDatastore());
for (String dataset : datasets) {
DatasetId datasetId = DatasetId.of(BigQueryTestConstants.PROJECT, dataset);
bigquery.create(DatasetInfo.of(datasetId));
}
for (String table : tables) {
TableDefinition tableDefinition = StandardTableDefinition.of(Schema.of(Field.of("test", Field.Type.string())));
TableId tableId = TableId.of(BigQueryTestConstants.PROJECT, datasets.get(0), table);
bigquery.create(TableInfo.of(tableId, tableDefinition));
}
}
use of com.google.cloud.bigquery.TableId in project beam by apache.
the class BigQueryClient method createTableIfNotExists.
/**
* Creates a new table with given schema when it not exists.
*
* @param tableName name of the desired table
* @param schema schema of consequent table fields (name, type pairs).
*/
public void createTableIfNotExists(String tableName, Map<String, String> schema) {
TableId tableId = TableId.of(projectId, dataset, tableName);
if (client.getTable(tableId, FIELD_OPTIONS) == null) {
List<Field> schemaFields = schema.entrySet().stream().map(entry -> Field.of(entry.getKey(), LegacySQLTypeName.valueOf(entry.getValue()))).collect(Collectors.toList());
createTable(tableId, Schema.of(schemaFields));
}
}
Aggregations