1717package com .google .cloud .bigquery ;
1818
1919import com .google .api .core .ApiFunction ;
20+ import com .google .api .services .bigquery .model .ExportDataStatistics ;
2021import com .google .api .services .bigquery .model .JobConfiguration ;
2122import com .google .api .services .bigquery .model .JobStatistics2 ;
2223import com .google .api .services .bigquery .model .JobStatistics3 ;
2324import com .google .api .services .bigquery .model .JobStatistics4 ;
2425import com .google .api .services .bigquery .model .JobStatistics5 ;
2526import com .google .api .services .bigquery .model .QueryParameter ;
27+ import com .google .auto .value .AutoValue ;
2628import com .google .cloud .StringEnumType ;
2729import com .google .cloud .StringEnumValue ;
2830import com .google .common .base .Function ;
3234import java .io .Serializable ;
3335import java .util .List ;
3436import java .util .Objects ;
37+ import javax .annotation .Nullable ;
3538import org .checkerframework .checker .nullness .compatqual .NullableDecl ;
3639
3740/** A Google BigQuery Job statistics. */
@@ -398,6 +401,7 @@ public static class QueryStatistics extends JobStatistics {
398401 private final Long estimatedBytesProcessed ;
399402 private final Long numDmlAffectedRows ;
400403 private final DmlStats dmlStats ;
404+ private final ExportDataStats exportDataStats ;
401405 private final List <TableId > referencedTables ;
402406 private final StatementType statementType ;
403407 private final Long totalBytesBilled ;
@@ -472,6 +476,80 @@ public static StatementType[] values() {
472476 }
473477 }
474478
479+ /**
480+ * Statistics for the EXPORT DATA statement as part of Query Job. EXTRACT JOB statistics are
481+ * populated in ExtractStatistics.
482+ */
483+ @ AutoValue
484+ public abstract static class ExportDataStats implements Serializable {
485+ private static final long serialVersionUID = 1L ;
486+
487+ /**
488+ * Returns number of destination files generated in case of EXPORT DATA statement only.
489+ *
490+ * @return value or {@code null} for none
491+ */
492+ @ Nullable
493+ public abstract Long getFileCount ();
494+
495+ /**
496+ * Returns number of destination rows generated in case of EXPORT DATA statement only.
497+ *
498+ * @return value or {@code null} for none
499+ */
500+ @ Nullable
501+ public abstract Long getRowCount ();
502+
503+ public abstract Builder toBuilder ();
504+
505+ public static Builder newBuilder () {
506+ return new AutoValue_JobStatistics_QueryStatistics_ExportDataStats .Builder ();
507+ }
508+
509+ static ExportDataStats fromPb (ExportDataStatistics exportDataStatisticsPb ) {
510+ Builder builder = newBuilder ();
511+ if (exportDataStatisticsPb .getFileCount () != null ) {
512+ builder .setFileCount (exportDataStatisticsPb .getFileCount ());
513+ }
514+ if (exportDataStatisticsPb .getRowCount () != null ) {
515+ builder .setRowCount (exportDataStatisticsPb .getRowCount ());
516+ }
517+ return builder .build ();
518+ }
519+
520+ ExportDataStatistics toPb () {
521+ ExportDataStatistics exportDataStatisticsPb = new ExportDataStatistics ();
522+ if (getFileCount () != null ) {
523+ exportDataStatisticsPb .setFileCount (getFileCount ());
524+ }
525+ if (getRowCount () != null ) {
526+ exportDataStatisticsPb .setRowCount (getRowCount ());
527+ }
528+ return exportDataStatisticsPb ;
529+ }
530+
531+ @ AutoValue .Builder
532+ public abstract static class Builder {
533+
534+ /**
535+ * Number of destination files generated in case of EXPORT DATA statement only.
536+ *
537+ * @param fileCount fileCount or {@code null} for none
538+ */
539+ public abstract Builder setFileCount (Long fileCount );
540+
541+ /**
542+ * Number of destination rows generated in case of EXPORT DATA statement only.
543+ *
544+ * @param rowCount rowCount or {@code null} for none
545+ */
546+ public abstract Builder setRowCount (Long rowCount );
547+
548+ /** Creates a {@code ExportDataStats} object. */
549+ public abstract ExportDataStats build ();
550+ }
551+ }
552+
475553 static final class Builder extends JobStatistics .Builder <QueryStatistics , Builder > {
476554
477555 private BiEngineStats biEngineStats ;
@@ -483,6 +561,7 @@ static final class Builder extends JobStatistics.Builder<QueryStatistics, Builde
483561 private Long estimatedBytesProcessed ;
484562 private Long numDmlAffectedRows ;
485563 private DmlStats dmlStats ;
564+ private ExportDataStats exportDataStats ;
486565 private List <TableId > referencedTables ;
487566 private StatementType statementType ;
488567 private Long totalBytesBilled ;
@@ -553,6 +632,10 @@ private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsP
553632 if (statisticsPb .getQuery ().getDmlStats () != null ) {
554633 this .dmlStats = DmlStats .fromPb (statisticsPb .getQuery ().getDmlStats ());
555634 }
635+ if (statisticsPb .getQuery ().getExportDataStatistics () != null ) {
636+ this .exportDataStats =
637+ ExportDataStats .fromPb (statisticsPb .getQuery ().getExportDataStatistics ());
638+ }
556639 }
557640 }
558641
@@ -601,6 +684,11 @@ Builder setDmlStats(DmlStats dmlStats) {
601684 return self ();
602685 }
603686
687+ Builder setExportDataStats (ExportDataStats exportDataStats ) {
688+ this .exportDataStats = exportDataStats ;
689+ return self ();
690+ }
691+
604692 Builder setReferenceTables (List <TableId > referencedTables ) {
605693 this .referencedTables = referencedTables ;
606694 return self ();
@@ -683,6 +771,7 @@ private QueryStatistics(Builder builder) {
683771 this .estimatedBytesProcessed = builder .estimatedBytesProcessed ;
684772 this .numDmlAffectedRows = builder .numDmlAffectedRows ;
685773 this .dmlStats = builder .dmlStats ;
774+ this .exportDataStats = builder .exportDataStats ;
686775 this .referencedTables = builder .referencedTables ;
687776 this .statementType = builder .statementType ;
688777 this .totalBytesBilled = builder .totalBytesBilled ;
@@ -749,6 +838,11 @@ public DmlStats getDmlStats() {
749838 return dmlStats ;
750839 }
751840
841+ /** Detailed statistics for EXPORT DATA statement. */
842+ public ExportDataStats getExportDataStats () {
843+ return exportDataStats ;
844+ }
845+
752846 /**
753847 * Referenced tables for the job. Queries that reference more than 50 tables will not have a
754848 * complete list.
@@ -900,6 +994,9 @@ com.google.api.services.bigquery.model.JobStatistics toPb() {
900994 if (dmlStats != null ) {
901995 queryStatisticsPb .setDmlStats (dmlStats .toPb ());
902996 }
997+ if (exportDataStats != null ) {
998+ queryStatisticsPb .setExportDataStatistics (exportDataStats .toPb ());
999+ }
9031000 if (referencedTables != null ) {
9041001 queryStatisticsPb .setReferencedTables (
9051002 Lists .transform (referencedTables , TableId .TO_PB_FUNCTION ));
0 commit comments