当前位置: 首页>>代码示例>>Java>>正文


Java JobConfigurationQuery类代码示例

本文整理汇总了Java中com.google.api.services.bigquery.model.JobConfigurationQuery的典型用法代码示例。如果您正苦于以下问题:Java JobConfigurationQuery类的具体用法?Java JobConfigurationQuery怎么用?Java JobConfigurationQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JobConfigurationQuery类属于com.google.api.services.bigquery.model包,在下文中一共展示了JobConfigurationQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dryRunQuery

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
@Override
public JobStatistics dryRunQuery(String projectId, JobConfigurationQuery queryConfig)
    throws InterruptedException, IOException {
  Job job = new Job()
      .setConfiguration(new JobConfiguration()
          .setQuery(queryConfig)
          .setDryRun(true));
  return executeWithRetries(
      client.jobs().insert(projectId, job),
      String.format(
          "Unable to dry run query: %s, aborting after %d retries.",
          queryConfig, MAX_RPC_RETRIES),
      Sleeper.DEFAULT,
      createDefaultBackoff(),
      ALWAYS_RETRY).getStatistics();
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:BigQueryServicesImpl.java

示例2: executeQuery

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
private void executeQuery(
    String executingProject,
    String jobId,
    TableReference destinationTable,
    JobService jobService) throws IOException, InterruptedException {
  JobReference jobRef = new JobReference()
      .setProjectId(executingProject)
      .setJobId(jobId);

  JobConfigurationQuery queryConfig = createBasicQueryConfig()
      .setAllowLargeResults(true)
      .setCreateDisposition("CREATE_IF_NEEDED")
      .setDestinationTable(destinationTable)
      .setPriority("BATCH")
      .setWriteDisposition("WRITE_EMPTY");

  jobService.startQueryJob(jobRef, queryConfig);
  Job job = jobService.pollJob(jobRef, JOB_POLL_MAX_RETRIES);
  if (BigQueryHelpers.parseStatus(job) != Status.SUCCEEDED) {
    throw new IOException(String.format(
        "Query job %s failed, status: %s.", jobId,
        BigQueryHelpers.statusToPrettyString(job.getStatus())));
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:25,代码来源:BigQueryQuerySource.java

示例3: query

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
/**
 * Starts an asynchronous query job to populate the specified destination table with the results
 * of the specified query, or if the table is a view, to update the view to reflect that query.
 * Returns a ListenableFuture that holds the same destination table object on success.
 */
public ListenableFuture<DestinationTable> query(
    String querySql,
    DestinationTable dest) {
  if (dest.type == TableType.VIEW) {
    // Use Futures.transform() rather than calling apply() directly so that any exceptions thrown
    // by calling updateTable will be propagated on the get() call, not from here.
    return transform(
        Futures.immediateFuture(dest.withQuery(querySql)), this::updateTable, directExecutor());
  } else {
    Job job = new Job()
        .setConfiguration(new JobConfiguration()
            .setQuery(new JobConfigurationQuery()
                .setQuery(querySql)
                .setDefaultDataset(getDataset())
                .setWriteDisposition(dest.getWriteDisposition().toString())
                .setDestinationTable(dest.getTableReference())));
    return transform(runJobToCompletion(job, dest), this::updateTable, directExecutor());
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:25,代码来源:BigqueryConnection.java

示例4: ensureTable

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
/** Create a table from a SQL query if it doesn't already exist. */
public TableReference ensureTable(TableReference table, String sqlQuery) {
  try {
    runJob(new Job()
        .setConfiguration(new JobConfiguration()
            .setQuery(new JobConfigurationQuery()
                .setQuery(sqlQuery)
                .setDefaultDataset(getDataset())
                .setDestinationTable(table))));
  } catch (BigqueryJobFailureException e) {
    if (e.getReason().equals("duplicate")) {
      // Table already exists.
    } else {
      throw e;
    }
  }
  return table;
}
 
开发者ID:google,项目名称:nomulus,代码行数:19,代码来源:BigqueryConnection.java

示例5: asyncQuery

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
/**
 * Inserts an asynchronous query Job for a particular query
 *
 * @param bigquery  an authorized BigQuery client
 * @param projectId a String containing the project ID
 * @param querySql  the actual query string
 * @return a reference to the inserted query job
 * @throws IOException
 */
public static Job asyncQuery(Bigquery bigquery, 
    String projectId,
    String querySql,
    boolean batch) throws IOException {
  
  JobConfigurationQuery query_config = new JobConfigurationQuery()
        .setQuery(querySql);
  
  if(batch){
    query_config.setPriority("BATCH");
  }
  
  Job job = new Job().setConfiguration(
      new JobConfiguration().setQuery(query_config));
          
  return bigquery.jobs().insert(projectId, job).execute();
}
 
开发者ID:googlearchive,项目名称:bigquery-samples-python,代码行数:27,代码来源:AsyncQuerySample.java

示例6: startQueryJob

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * <p>Tries executing the RPC for at most {@code MAX_RPC_RETRIES} times until it succeeds.
 *
 * @throws IOException if it exceeds {@code MAX_RPC_RETRIES} attempts.
 */
@Override
public void startQueryJob(JobReference jobRef, JobConfigurationQuery queryConfig)
    throws IOException, InterruptedException {
  Job job = new Job()
      .setJobReference(jobRef)
      .setConfiguration(
          new JobConfiguration().setQuery(queryConfig));

  startJob(job, errorExtractor, client);
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:BigQueryServicesImpl.java

示例7: startQueryJob

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
@Override
public void startQueryJob(JobReference jobRef, JobConfigurationQuery query)
    throws IOException, InterruptedException {
  synchronized (allJobs) {
    Job job = new Job();
    job.setJobReference(jobRef);
    job.setConfiguration(new JobConfiguration().setQuery(query));
    job.setKind(" bigquery#job");
    job.setStatus(new JobStatus().setState("PENDING"));
    allJobs.put(jobRef.getProjectId(), jobRef.getJobId(), new JobInfo(job));
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:FakeJobService.java

示例8: dryRunQuery

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
@Override
public JobStatistics dryRunQuery(String projectId, JobConfigurationQuery query)
    throws InterruptedException, IOException {
  synchronized (dryRunQueryResults) {
    JobStatistics result = dryRunQueryResults.get(projectId, query.getQuery());
    if (result != null) {
      return result;
    }
  }
  throw new UnsupportedOperationException();
}
 
开发者ID:apache,项目名称:beam,代码行数:12,代码来源:FakeJobService.java

示例9: runQueryJob

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
private JobStatus runQueryJob(JobConfigurationQuery query)
    throws IOException, InterruptedException  {
  List<TableRow> rows = FakeBigQueryServices.rowsFromEncodedQuery(query.getQuery());
  datasetService.createTable(new Table().setTableReference(query.getDestinationTable()));
  datasetService.insertAll(query.getDestinationTable(), rows, null);
  return new JobStatus().setState("DONE");
}
 
开发者ID:apache,项目名称:beam,代码行数:8,代码来源:FakeJobService.java

示例10: queryToLocalTable

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
/**
 * Starts an asynchronous query job to dump the results of the specified query into a local
 * ImmutableTable object, row-keyed by the row number (indexed from 1), column-keyed by the
 * TableFieldSchema for that column, and with the value object as the cell value.  Note that null
 * values will not actually be null, but they can be checked for using Data.isNull().
 *
 * <p>Returns a ListenableFuture that holds the ImmutableTable on success.
 */
public ListenableFuture<ImmutableTable<Integer, TableFieldSchema, Object>>
    queryToLocalTable(String querySql) throws Exception {
  Job job = new Job()
      .setConfiguration(new JobConfiguration()
          .setQuery(new JobConfigurationQuery()
              .setQuery(querySql)
              .setDefaultDataset(getDataset())));
  return transform(runJobToCompletion(job), this::getQueryResults, directExecutor());
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:BigqueryConnection.java

示例11: queryToLocalTableSync

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
/**
 * Returns the result of calling queryToLocalTable, but synchronously to avoid spawning new
 * background threads, which App Engine doesn't support.
 *
 * @see <a href="https://cloud.google.com/appengine/docs/standard/java/runtime#Threads">
 *   App Engine Runtime</a>
 *
 * <p>Returns the results of the query in an ImmutableTable on success.
 */
public ImmutableTable<Integer, TableFieldSchema, Object> queryToLocalTableSync(String querySql)
    throws Exception {
  Job job = new Job()
      .setConfiguration(new JobConfiguration()
          .setQuery(new JobConfigurationQuery()
              .setQuery(querySql)
              .setDefaultDataset(getDataset())));
  return getQueryResults(runJob(job));
}
 
开发者ID:google,项目名称:nomulus,代码行数:19,代码来源:BigqueryConnection.java

示例12: run

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
@Override
public void run() throws Exception {
  checkArgument(output.toUri().getScheme().equals("gs"),
      "Not a valid cloud storage URI: %s", output);
  checkArgument(end.isAfter(start), "End time must be after start time");
  try (BigqueryConnection bq = bigqueryParameters.newConnection()) {
    bq.ensureTable(bq.getTable("ReportingIdentifiers"),
        getSql("ReportingIdentifiers.sql")
            .build());
    bq.ensureTable(bq.getTable("ReportingHistory"),
        getSql("ReportingHistory.sql")
            .build());
    Job job = bq.runJob(new Job()
        .setConfiguration(new JobConfiguration()
            .setQuery(new JobConfigurationQuery()
                .setDefaultDataset(bq.getDataset())
                .setQuery(getSql("registrar_activity_report.sql")
                    .put("STARTTIME", BIGQUERY_TIMESTAMP_FORMATTER.print(start))
                    .put("ENDTIME", BIGQUERY_TIMESTAMP_FORMATTER.print(end))
                    .put("REGISTRAR", registrarClientId)
                    .put("TLD", tld)
                    .build()))));
    bq.runJob(new Job()
        .setConfiguration(new JobConfiguration()
            .setExtract(new JobConfigurationExtract()
                .setPrintHeader(true)
                .setDestinationFormat("CSV")
                .setDestinationUris(ImmutableList.of(output.toUri().toString()))
                .setSourceTable(job.getConfiguration().getQuery().getDestinationTable()))));
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:32,代码来源:RegistrarActivityReportCommand.java

示例13: jobConfiguration

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
@Override
protected JobConfiguration jobConfiguration(String projectId)
{
    JobConfigurationQuery cfg = new JobConfigurationQuery()
            .setQuery(query);

    cfg.setUseLegacySql(params.get("use_legacy_sql", boolean.class, false));

    params.getOptional("allow_large_results", boolean.class).transform(cfg::setAllowLargeResults);
    params.getOptional("use_query_cache", Boolean.class).transform(cfg::setUseQueryCache);
    params.getOptional("create_disposition", String.class).transform(cfg::setCreateDisposition);
    params.getOptional("write_disposition", String.class).transform(cfg::setWriteDisposition);
    params.getOptional("flatten_results", Boolean.class).transform(cfg::setFlattenResults);
    params.getOptional("maximum_billing_tier", Integer.class).transform(cfg::setMaximumBillingTier);
    params.getOptional("priority", String.class).transform(cfg::setPriority);

    params.getOptional("table_definitions", new TypeReference<Map<String, ExternalDataConfiguration>>() {})
            .transform(cfg::setTableDefinitions);
    params.getOptional("user_defined_function_resources", new TypeReference<List<UserDefinedFunctionResource>>() {})
            .transform(cfg::setUserDefinedFunctionResources);

    Optional<DatasetReference> defaultDataset = params.getOptional("dataset", String.class)
            .transform(Bq::datasetReference);
    defaultDataset.transform(cfg::setDefaultDataset);

    params.getOptional("destination_table", String.class)
            .transform(s -> cfg.setDestinationTable(tableReference(projectId, defaultDataset, s)));

    return new JobConfiguration()
            .setQuery(cfg);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:32,代码来源:BqOperatorFactory.java

示例14: createBasicQueryConfig

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
private JobConfigurationQuery createBasicQueryConfig() {
  return new JobConfigurationQuery()
      .setFlattenResults(flattenResults)
      .setQuery(query.get())
      .setUseLegacySql(useLegacySql);
}
 
开发者ID:apache,项目名称:beam,代码行数:7,代码来源:BigQueryQuerySource.java

示例15: runQuery

import com.google.api.services.bigquery.model.JobConfigurationQuery; //导入依赖的package包/类
/**
 * Runs the query in BigQuery and writes results to a temporary table.
 *
 * @param bigquery the Bigquery instance to use.
 * @param projectId the project on whose behalf the query will be run.
 * @param tableRef the table to write the results to.
 * @param query the query to run.
 * @throws IOException on IO error.
 * @throws InterruptedException on interrupt.
 */
@VisibleForTesting
static void runQuery(
    BigQueryHelper bigQueryHelper, String projectId, TableReference tableRef, String query)
    throws IOException, InterruptedException {
  LOG.debug("runQuery(bigquery, '{}', '{}', '{}')",
      projectId, BigQueryStrings.toString(tableRef), query);

  // Create a query statement and query request object.
  JobConfigurationQuery queryConfig = new JobConfigurationQuery();
  queryConfig.setAllowLargeResults(true);
  queryConfig.setQuery(query);

  // Set the table to put results into.
  queryConfig.setDestinationTable(tableRef);

  // Require table to be empty.
  queryConfig.setWriteDisposition("WRITE_EMPTY");

  JobConfiguration config = new JobConfiguration();
  config.setQuery(queryConfig);

  JobReference jobReference = bigQueryHelper.createJobReference(projectId, "querybasedexport");

  Job job = new Job();
  job.setConfiguration(config);
  job.setJobReference(jobReference);

  // Run the job.
  Job response = bigQueryHelper.insertJobOrFetchDuplicate(projectId, job);
  LOG.debug("Got response '{}'", response);

  // Create anonymous Progressable object
  Progressable progressable = new Progressable() {
    @Override
    public void progress() {
      // TODO(user): ensure task doesn't time out
    }
  };

  // Poll until job is complete.
  BigQueryUtils.waitForJobCompletion(
      bigQueryHelper.getRawBigquery(), projectId, jobReference, progressable);
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:54,代码来源:QueryBasedExport.java


注:本文中的com.google.api.services.bigquery.model.JobConfigurationQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。