@@ -842,6 +842,70 @@ Creation, truncation and append actions occur as one atomic update upon job comp
842842 Default : "US" ,
843843 },
844844
845+ "status" : {
846+ Type : schema .TypeList ,
847+ Computed : true ,
848+ Description : `The status of this job. Examine this value when polling an asynchronous job to see if the job is complete.` ,
849+ Elem : & schema.Resource {
850+ Schema : map [string ]* schema.Schema {
851+ "error_result" : {
852+ Type : schema .TypeList ,
853+ Computed : true ,
854+ Description : `Final error result of the job. If present, indicates that the job has completed and was unsuccessful.` ,
855+ Elem : & schema.Resource {
856+ Schema : map [string ]* schema.Schema {
857+ "location" : {
858+ Type : schema .TypeString ,
859+ Optional : true ,
860+ Description : `Specifies where the error occurred, if present.` ,
861+ },
862+ "message" : {
863+ Type : schema .TypeString ,
864+ Optional : true ,
865+ Description : `A human-readable description of the error.` ,
866+ },
867+ "reason" : {
868+ Type : schema .TypeString ,
869+ Optional : true ,
870+ Description : `A short error code that summarizes the error.` ,
871+ },
872+ },
873+ },
874+ },
875+ "errors" : {
876+ Type : schema .TypeList ,
877+ Computed : true ,
878+ Description : `The first errors encountered during the running of the job. The final message
879+ includes the number of errors that caused the process to stop. Errors here do
880+ not necessarily mean that the job has not completed or was unsuccessful.` ,
881+ Elem : & schema.Resource {
882+ Schema : map [string ]* schema.Schema {
883+ "location" : {
884+ Type : schema .TypeString ,
885+ Optional : true ,
886+ Description : `Specifies where the error occurred, if present.` ,
887+ },
888+ "message" : {
889+ Type : schema .TypeString ,
890+ Optional : true ,
891+ Description : `A human-readable description of the error.` ,
892+ },
893+ "reason" : {
894+ Type : schema .TypeString ,
895+ Optional : true ,
896+ Description : `A short error code that summarizes the error.` ,
897+ },
898+ },
899+ },
900+ },
901+ "state" : {
902+ Type : schema .TypeString ,
903+ Computed : true ,
904+ Description : `Running state of the job. Valid states include 'PENDING', 'RUNNING', and 'DONE'.` ,
905+ },
906+ },
907+ },
908+ },
845909 "user_email" : {
846910 Type : schema .TypeString ,
847911 Computed : true ,
@@ -1027,6 +1091,9 @@ func resourceBigQueryJobRead(d *schema.ResourceData, meta interface{}) error {
10271091 }
10281092 }
10291093 }
1094+ if err := d .Set ("status" , flattenBigQueryJobStatus (res ["status" ], d , config )); err != nil {
1095+ return fmt .Errorf ("Error reading Job: %s" , err )
1096+ }
10301097
10311098 return nil
10321099}
@@ -1744,6 +1811,88 @@ func flattenBigQueryJobJobReferenceLocation(v interface{}, d *schema.ResourceDat
17441811 return v
17451812}
17461813
1814+ func flattenBigQueryJobStatus (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1815+ if v == nil {
1816+ return nil
1817+ }
1818+ original := v .(map [string ]interface {})
1819+ if len (original ) == 0 {
1820+ return nil
1821+ }
1822+ transformed := make (map [string ]interface {})
1823+ transformed ["error_result" ] =
1824+ flattenBigQueryJobStatusErrorResult (original ["errorResult" ], d , config )
1825+ transformed ["errors" ] =
1826+ flattenBigQueryJobStatusErrors (original ["errors" ], d , config )
1827+ transformed ["state" ] =
1828+ flattenBigQueryJobStatusState (original ["state" ], d , config )
1829+ return []interface {}{transformed }
1830+ }
1831+ func flattenBigQueryJobStatusErrorResult (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1832+ if v == nil {
1833+ return nil
1834+ }
1835+ original := v .(map [string ]interface {})
1836+ if len (original ) == 0 {
1837+ return nil
1838+ }
1839+ transformed := make (map [string ]interface {})
1840+ transformed ["reason" ] =
1841+ flattenBigQueryJobStatusErrorResultReason (original ["reason" ], d , config )
1842+ transformed ["location" ] =
1843+ flattenBigQueryJobStatusErrorResultLocation (original ["location" ], d , config )
1844+ transformed ["message" ] =
1845+ flattenBigQueryJobStatusErrorResultMessage (original ["message" ], d , config )
1846+ return []interface {}{transformed }
1847+ }
1848+ func flattenBigQueryJobStatusErrorResultReason (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1849+ return v
1850+ }
1851+
1852+ func flattenBigQueryJobStatusErrorResultLocation (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1853+ return v
1854+ }
1855+
1856+ func flattenBigQueryJobStatusErrorResultMessage (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1857+ return v
1858+ }
1859+
1860+ func flattenBigQueryJobStatusErrors (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1861+ if v == nil {
1862+ return v
1863+ }
1864+ l := v .([]interface {})
1865+ transformed := make ([]interface {}, 0 , len (l ))
1866+ for _ , raw := range l {
1867+ original := raw .(map [string ]interface {})
1868+ if len (original ) < 1 {
1869+ // Do not include empty json objects coming back from the api
1870+ continue
1871+ }
1872+ transformed = append (transformed , map [string ]interface {}{
1873+ "reason" : flattenBigQueryJobStatusErrorsReason (original ["reason" ], d , config ),
1874+ "location" : flattenBigQueryJobStatusErrorsLocation (original ["location" ], d , config ),
1875+ "message" : flattenBigQueryJobStatusErrorsMessage (original ["message" ], d , config ),
1876+ })
1877+ }
1878+ return transformed
1879+ }
1880+ func flattenBigQueryJobStatusErrorsReason (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1881+ return v
1882+ }
1883+
1884+ func flattenBigQueryJobStatusErrorsLocation (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1885+ return v
1886+ }
1887+
1888+ func flattenBigQueryJobStatusErrorsMessage (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1889+ return v
1890+ }
1891+
1892+ func flattenBigQueryJobStatusState (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1893+ return v
1894+ }
1895+
17471896func expandBigQueryJobConfiguration (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
17481897 transformed := make (map [string ]interface {})
17491898 transformedJobType , err := expandBigQueryJobConfigurationJobType (d .Get ("job_type" ), d , config )
0 commit comments