@@ -52,7 +52,7 @@ import {
5252} from '.' ;
5353import { GoogleErrorBody } from '@google-cloud/common/build/src/util' ;
5454import { Duplex , Writable } from 'stream' ;
55- import { JobMetadata } from './job' ;
55+ import { JobMetadata , JobOptions } from './job' ;
5656import bigquery from './types' ;
5757import { IntegerTypeCastOptions } from './bigquery' ;
5858import { RowQueue } from './rowQueue' ;
@@ -923,8 +923,7 @@ class Table extends ServiceObject {
923923 const callback =
924924 typeof metadataOrCallback === 'function' ? metadataOrCallback : cb ;
925925
926- // eslint-disable-next-line @typescript-eslint/no-explicit-any
927- const body : any = {
926+ const body : JobOptions = {
928927 configuration : {
929928 copy : extend ( true , metadata , {
930929 destinationTable : {
@@ -955,6 +954,11 @@ class Table extends ServiceObject {
955954 delete metadata . jobId ;
956955 }
957956
957+ if ( body . configuration && metadata . reservation ) {
958+ body . configuration . reservation = metadata . reservation ;
959+ delete metadata . reservation ;
960+ }
961+
958962 this . bigQuery . createJob ( body , callback ! ) ;
959963 }
960964
@@ -1045,8 +1049,7 @@ class Table extends ServiceObject {
10451049 const callback =
10461050 typeof metadataOrCallback === 'function' ? metadataOrCallback : cb ;
10471051
1048- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1049- const body : any = {
1052+ const body : JobOptions = {
10501053 configuration : {
10511054 copy : extend ( true , metadata , {
10521055 destinationTable : {
@@ -1080,6 +1083,11 @@ class Table extends ServiceObject {
10801083 delete metadata . jobId ;
10811084 }
10821085
1086+ if ( body . configuration && metadata . reservation ) {
1087+ body . configuration . reservation = metadata . reservation ;
1088+ delete metadata . reservation ;
1089+ }
1090+
10831091 this . bigQuery . createJob ( body , callback ! ) ;
10841092 }
10851093
@@ -1218,8 +1226,7 @@ class Table extends ServiceObject {
12181226 delete options . gzip ;
12191227 }
12201228
1221- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1222- const body : any = {
1229+ const body : JobOptions = {
12231230 configuration : {
12241231 extract : extend ( true , options , {
12251232 sourceTable : {
@@ -1245,6 +1252,11 @@ class Table extends ServiceObject {
12451252 delete options . jobId ;
12461253 }
12471254
1255+ if ( body . configuration && options . reservation ) {
1256+ body . configuration . reservation = options . reservation ;
1257+ delete options . reservation ;
1258+ }
1259+
12481260 this . bigQuery . createJob ( body , callback ! ) ;
12491261 }
12501262
@@ -1399,8 +1411,7 @@ class Table extends ServiceObject {
13991411 return [ jobResponse , jobResponse . metadata ] ;
14001412 }
14011413
1402- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1403- const body : any = {
1414+ const body : JobOptions = {
14041415 configuration : {
14051416 load : {
14061417 destinationTable : {
@@ -1427,7 +1438,12 @@ class Table extends ServiceObject {
14271438 delete metadata . jobId ;
14281439 }
14291440
1430- extend ( true , body . configuration . load , metadata , {
1441+ if ( body . configuration && metadata . reservation ) {
1442+ body . configuration . reservation = metadata . reservation ;
1443+ delete metadata . reservation ;
1444+ }
1445+
1446+ extend ( true , body . configuration ?. load , metadata , {
14311447 sourceUris : toArray ( source ) . map ( src => {
14321448 if ( ! util . isCustomType ( src , 'storage/file' ) ) {
14331449 throw new Error ( 'Source must be a File object.' ) ;
@@ -1437,7 +1453,12 @@ class Table extends ServiceObject {
14371453 // the file's extension. If no match, don't set, and default upstream
14381454 // to CSV.
14391455 const format = FORMATS [ path . extname ( src . name ) . substr ( 1 ) . toLowerCase ( ) ] ;
1440- if ( ! metadata . sourceFormat && format ) {
1456+ if (
1457+ ! metadata . sourceFormat &&
1458+ format &&
1459+ body . configuration &&
1460+ body . configuration . load
1461+ ) {
14411462 body . configuration . load . sourceFormat = format ;
14421463 }
14431464 return 'gs://' + src . bucket . name + '/' + src . name ;
0 commit comments