17
17
package com .google .cloud .bigquery ;
18
18
19
19
import com .google .api .core .ApiFunction ;
20
+ import com .google .api .services .bigquery .model .ExportDataStatistics ;
20
21
import com .google .api .services .bigquery .model .JobConfiguration ;
21
22
import com .google .api .services .bigquery .model .JobStatistics2 ;
22
23
import com .google .api .services .bigquery .model .JobStatistics3 ;
23
24
import com .google .api .services .bigquery .model .JobStatistics4 ;
24
25
import com .google .api .services .bigquery .model .JobStatistics5 ;
25
26
import com .google .api .services .bigquery .model .QueryParameter ;
27
+ import com .google .auto .value .AutoValue ;
26
28
import com .google .cloud .StringEnumType ;
27
29
import com .google .cloud .StringEnumValue ;
28
30
import com .google .common .base .Function ;
32
34
import java .io .Serializable ;
33
35
import java .util .List ;
34
36
import java .util .Objects ;
37
+ import javax .annotation .Nullable ;
35
38
import org .checkerframework .checker .nullness .compatqual .NullableDecl ;
36
39
37
40
/** A Google BigQuery Job statistics. */
@@ -398,6 +401,7 @@ public static class QueryStatistics extends JobStatistics {
398
401
private final Long estimatedBytesProcessed ;
399
402
private final Long numDmlAffectedRows ;
400
403
private final DmlStats dmlStats ;
404
+ private final ExportDataStats exportDataStats ;
401
405
private final List <TableId > referencedTables ;
402
406
private final StatementType statementType ;
403
407
private final Long totalBytesBilled ;
@@ -472,6 +476,80 @@ public static StatementType[] values() {
472
476
}
473
477
}
474
478
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
+
475
553
static final class Builder extends JobStatistics .Builder <QueryStatistics , Builder > {
476
554
477
555
private BiEngineStats biEngineStats ;
@@ -483,6 +561,7 @@ static final class Builder extends JobStatistics.Builder<QueryStatistics, Builde
483
561
private Long estimatedBytesProcessed ;
484
562
private Long numDmlAffectedRows ;
485
563
private DmlStats dmlStats ;
564
+ private ExportDataStats exportDataStats ;
486
565
private List <TableId > referencedTables ;
487
566
private StatementType statementType ;
488
567
private Long totalBytesBilled ;
@@ -553,6 +632,10 @@ private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsP
553
632
if (statisticsPb .getQuery ().getDmlStats () != null ) {
554
633
this .dmlStats = DmlStats .fromPb (statisticsPb .getQuery ().getDmlStats ());
555
634
}
635
+ if (statisticsPb .getQuery ().getExportDataStatistics () != null ) {
636
+ this .exportDataStats =
637
+ ExportDataStats .fromPb (statisticsPb .getQuery ().getExportDataStatistics ());
638
+ }
556
639
}
557
640
}
558
641
@@ -601,6 +684,11 @@ Builder setDmlStats(DmlStats dmlStats) {
601
684
return self ();
602
685
}
603
686
687
+ Builder setExportDataStats (ExportDataStats exportDataStats ) {
688
+ this .exportDataStats = exportDataStats ;
689
+ return self ();
690
+ }
691
+
604
692
Builder setReferenceTables (List <TableId > referencedTables ) {
605
693
this .referencedTables = referencedTables ;
606
694
return self ();
@@ -683,6 +771,7 @@ private QueryStatistics(Builder builder) {
683
771
this .estimatedBytesProcessed = builder .estimatedBytesProcessed ;
684
772
this .numDmlAffectedRows = builder .numDmlAffectedRows ;
685
773
this .dmlStats = builder .dmlStats ;
774
+ this .exportDataStats = builder .exportDataStats ;
686
775
this .referencedTables = builder .referencedTables ;
687
776
this .statementType = builder .statementType ;
688
777
this .totalBytesBilled = builder .totalBytesBilled ;
@@ -749,6 +838,11 @@ public DmlStats getDmlStats() {
749
838
return dmlStats ;
750
839
}
751
840
841
+ /** Detailed statistics for EXPORT DATA statement. */
842
+ public ExportDataStats getExportDataStats () {
843
+ return exportDataStats ;
844
+ }
845
+
752
846
/**
753
847
* Referenced tables for the job. Queries that reference more than 50 tables will not have a
754
848
* complete list.
@@ -900,6 +994,9 @@ com.google.api.services.bigquery.model.JobStatistics toPb() {
900
994
if (dmlStats != null ) {
901
995
queryStatisticsPb .setDmlStats (dmlStats .toPb ());
902
996
}
997
+ if (exportDataStats != null ) {
998
+ queryStatisticsPb .setExportDataStatistics (exportDataStats .toPb ());
999
+ }
903
1000
if (referencedTables != null ) {
904
1001
queryStatisticsPb .setReferencedTables (
905
1002
Lists .transform (referencedTables , TableId .TO_PB_FUNCTION ));
0 commit comments