本文整理汇总了Java中org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java WriteDisposition.valueOf方法的具体用法?Java WriteDisposition.valueOf怎么用?Java WriteDisposition.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition
的用法示例。
在下文中一共展示了WriteDisposition.valueOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runLoadJob
import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition; //导入方法依赖的package包/类
private JobStatus runLoadJob(JobReference jobRef, JobConfigurationLoad load)
throws InterruptedException, IOException {
TableReference destination = load.getDestinationTable();
TableSchema schema = load.getSchema();
checkArgument(schema != null, "No schema specified");
List<ResourceId> sourceFiles = filesForLoadJobs.get(jobRef.getProjectId(), jobRef.getJobId());
WriteDisposition writeDisposition = WriteDisposition.valueOf(load.getWriteDisposition());
CreateDisposition createDisposition = CreateDisposition.valueOf(load.getCreateDisposition());
checkArgument(load.getSourceFormat().equals("NEWLINE_DELIMITED_JSON"));
Table existingTable = datasetService.getTable(destination);
if (!validateDispositions(existingTable, createDisposition, writeDisposition)) {
return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
}
if (existingTable == null) {
TableReference strippedDestination =
destination
.clone()
.setTableId(BigQueryHelpers.stripPartitionDecorator(destination.getTableId()));
existingTable =
new Table()
.setTableReference(strippedDestination)
.setSchema(schema);
if (load.getTimePartitioning() != null) {
existingTable = existingTable.setTimePartitioning(load.getTimePartitioning());
}
datasetService.createTable(existingTable);
}
List<TableRow> rows = Lists.newArrayList();
for (ResourceId filename : sourceFiles) {
rows.addAll(readRows(filename.toString()));
}
datasetService.insertAll(destination, rows, null);
FileSystems.delete(sourceFiles);
return new JobStatus().setState("DONE");
}
示例2: runCopyJob
import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition; //导入方法依赖的package包/类
private JobStatus runCopyJob(JobConfigurationTableCopy copy)
throws InterruptedException, IOException {
List<TableReference> sources = copy.getSourceTables();
TableReference destination = copy.getDestinationTable();
WriteDisposition writeDisposition = WriteDisposition.valueOf(copy.getWriteDisposition());
CreateDisposition createDisposition = CreateDisposition.valueOf(copy.getCreateDisposition());
Table existingTable = datasetService.getTable(destination);
if (!validateDispositions(existingTable, createDisposition, writeDisposition)) {
return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
}
TimePartitioning partitioning = null;
TableSchema schema = null;
boolean first = true;
List<TableRow> allRows = Lists.newArrayList();
for (TableReference source : sources) {
Table table = checkNotNull(datasetService.getTable(source));
if (!first) {
if (partitioning != table.getTimePartitioning()) {
return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
}
if (schema != table.getSchema()) {
return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
}
}
partitioning = table.getTimePartitioning();
schema = table.getSchema();
first = false;
allRows.addAll(datasetService.getAllRows(
source.getProjectId(), source.getDatasetId(), source.getTableId()));
}
datasetService.createTable(new Table()
.setTableReference(destination)
.setSchema(schema)
.setTimePartitioning(partitioning));
datasetService.insertAll(destination, allRows, null);
return new JobStatus().setState("DONE");
}