File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1518,6 +1518,9 @@ export class BigQuery extends common.Service {
1518
1518
callback ?: JobCallback
1519
1519
) : void | Promise < JobResponse > {
1520
1520
const JOB_ID_PROVIDED = typeof options . jobId !== 'undefined' ;
1521
+ const DRY_RUN = options . configuration ?. dryRun
1522
+ ? options . configuration . dryRun
1523
+ : false ;
1521
1524
1522
1525
const reqOpts = Object . assign ( { } , options ) ;
1523
1526
let jobId = JOB_ID_PROVIDED ? reqOpts . jobId : uuid . v4 ( ) ;
@@ -1558,7 +1561,8 @@ export class BigQuery extends common.Service {
1558
1561
if ( err ) {
1559
1562
if (
1560
1563
( err as common . ApiError ) . code === ALREADY_EXISTS_CODE &&
1561
- ! JOB_ID_PROVIDED
1564
+ ! JOB_ID_PROVIDED &&
1565
+ ! DRY_RUN
1562
1566
) {
1563
1567
// The last insert attempt flaked, but the API still processed the
1564
1568
// request and created the job. Because of our "autoRetry" feature,
Original file line number Diff line number Diff line change @@ -1749,6 +1749,20 @@ describe('BigQuery', () => {
1749
1749
} ) ;
1750
1750
} ) ;
1751
1751
1752
+ it ( 'should return 409 if dryRun is true' , done => {
1753
+ const error = new util . ApiError ( 'Error.' ) ;
1754
+ error . code = 409 ;
1755
+
1756
+ bq . request = ( reqOpts : DecorateRequestOptions , callback : Function ) => {
1757
+ callback ( error ) ;
1758
+ } ;
1759
+
1760
+ bq . createJob ( { configuration : { dryRun : true } } , ( err : Error ) => {
1761
+ assert . strictEqual ( err , error ) ;
1762
+ done ( ) ;
1763
+ } ) ;
1764
+ } ) ;
1765
+
1752
1766
it ( 'should return any status errors' , done => {
1753
1767
const errors = [ { reason : 'notFound' } ] ;
1754
1768
const response = extend ( true , { } , RESPONSE , {
You can’t perform that action at this time.
0 commit comments