コード例 #1
0
 @Override
 com.google.api.services.bigquery.model.JobConfiguration toPb() {
   com.google.api.services.bigquery.model.JobConfiguration configurationPb =
       new com.google.api.services.bigquery.model.JobConfiguration();
   JobConfigurationQuery queryConfigurationPb = new JobConfigurationQuery();
   queryConfigurationPb.setQuery(query);
   configurationPb.setDryRun(dryRun());
   if (allowLargeResults != null) {
     queryConfigurationPb.setAllowLargeResults(allowLargeResults);
   }
   if (createDisposition != null) {
     queryConfigurationPb.setCreateDisposition(createDisposition.toString());
   }
   if (destinationTable != null) {
     queryConfigurationPb.setDestinationTable(destinationTable.toPb());
   }
   if (defaultDataset != null) {
     queryConfigurationPb.setDefaultDataset(defaultDataset.toPb());
   }
   if (flattenResults != null) {
     queryConfigurationPb.setFlattenResults(flattenResults);
   }
   if (priority != null) {
     queryConfigurationPb.setPriority(priority.toString());
   }
   if (tableDefinitions != null) {
     queryConfigurationPb.setTableDefinitions(
         Maps.transformValues(
             tableDefinitions, ExternalTableDefinition.TO_EXTERNAL_DATA_FUNCTION));
   }
   if (useQueryCache != null) {
     queryConfigurationPb.setUseQueryCache(useQueryCache);
   }
   if (userDefinedFunctions != null) {
     queryConfigurationPb.setUserDefinedFunctionResources(
         Lists.transform(userDefinedFunctions, UserDefinedFunction.TO_PB_FUNCTION));
   }
   if (writeDisposition != null) {
     queryConfigurationPb.setWriteDisposition(writeDisposition.toString());
   }
   return configurationPb.setQuery(queryConfigurationPb);
 }
コード例 #2
0
 private Builder(com.google.api.services.bigquery.model.JobConfiguration configurationPb) {
   this();
   JobConfigurationQuery queryConfigurationPb = configurationPb.getQuery();
   this.query = queryConfigurationPb.getQuery();
   allowLargeResults = queryConfigurationPb.getAllowLargeResults();
   useQueryCache = queryConfigurationPb.getUseQueryCache();
   flattenResults = queryConfigurationPb.getFlattenResults();
   dryRun = configurationPb.getDryRun();
   if (queryConfigurationPb.getDestinationTable() != null) {
     destinationTable = TableId.fromPb(queryConfigurationPb.getDestinationTable());
   }
   if (queryConfigurationPb.getDefaultDataset() != null) {
     defaultDataset = DatasetId.fromPb(queryConfigurationPb.getDefaultDataset());
   }
   if (queryConfigurationPb.getPriority() != null) {
     priority = Priority.valueOf(queryConfigurationPb.getPriority());
   }
   if (queryConfigurationPb.getTableDefinitions() != null) {
     tableDefinitions =
         Maps.transformValues(
             queryConfigurationPb.getTableDefinitions(),
             ExternalTableDefinition.FROM_EXTERNAL_DATA_FUNCTION);
   }
   if (queryConfigurationPb.getUserDefinedFunctionResources() != null) {
     userDefinedFunctions =
         Lists.transform(
             queryConfigurationPb.getUserDefinedFunctionResources(),
             UserDefinedFunction.FROM_PB_FUNCTION);
   }
   if (queryConfigurationPb.getCreateDisposition() != null) {
     createDisposition = CreateDisposition.valueOf(queryConfigurationPb.getCreateDisposition());
   }
   if (queryConfigurationPb.getWriteDisposition() != null) {
     writeDisposition = WriteDisposition.valueOf(queryConfigurationPb.getWriteDisposition());
   }
 }