BigQuery/src/Table.php
private function handleInsert(array $options)
    {
        $attempt = 0;
        $metadata = $this->pluck('tableMetadata', $options, false) ?: [];
        $autoCreate = $this->pluck('autoCreate', $options, false) ?: false;
        $maxRetries = $this->pluck('maxRetries', $options, false) ?: self::MAX_RETRIES;

        while (true) {
            try {
                return $this->connection->insertAllTableData(
                    $this->identity + $options
                );
            } catch (NotFoundException $ex) {
                if ($autoCreate === true && $attempt <= $maxRetries) {
                    if (!isset($metadata['schema'])) {
                        throw new \InvalidArgumentException(
                            'A schema is required when creating a table.'
                        );
                    }

                    $this->usleep(mt_rand(1, self::INSERT_CREATE_MAX_DELAY_MICROSECONDS));

                    try {
                        $this->connection->insertTable($metadata + [
                            'projectId' => $this->identity['projectId'],
                            'datasetId' => $this->identity['datasetId'],
                            'tableReference' => $this->identity,
                            'retries' => 0
                        ]);
                    } catch (ConflictException $ex) {
                    } catch (\Exception $ex) {
                        $retryFunction = $this->getRetryFunction();

                        if (!$retryFunction($ex)) {
                            throw $ex;
                        }
                    }

                    $this->usleep(self::INSERT_CREATE_MAX_DELAY_MICROSECONDS);
                    $attempt++;
                } else {
                    throw $ex;
                }
            }
        }
    }
private function handleInsert(array $options)
    {
        $attempt = 0;
        $metadata = $this->pluck('tableMetadata', $options, false) ?: [];
        $autoCreate = $this->pluck('autoCreate', $options, false) ?: false;
        $maxRetries = $this->pluck('maxRetries', $options, false) ?: self::MAX_RETRIES;

        while (true) {
            try {
                return $this->connection->insertAllTableData(
                    $this->identity + $options
                );
            } catch (NotFoundException $ex) {
                if ($autoCreate === true && $attempt <= $maxRetries) {
                    if (!isset($metadata['schema'])) {
                        throw new \InvalidArgumentException(
                            'A schema is required when creating a table.'
                        );
                    }

                    $this->usleep(mt_rand(1, self::INSERT_CREATE_MAX_DELAY_MICROSECONDS));

                    try {
                        $this->connection->insertTable($metadata + [
                            'projectId' => $this->identity['projectId'],
                            'datasetId' => $this->identity['datasetId'],
                            'tableReference' => $this->identity,
                            'retries' => 0
                        ]);
                    } catch (ConflictException $ex) {
                    } catch (\Exception $ex) {
                        $retryFunction = $this->getRetryFunction();

                        if (!$retryFunction($ex)) {
                            throw $ex;
                        }
                    }

                    $this->usleep(self::INSERT_CREATE_MAX_DELAY_MICROSECONDS);
                    $attempt++;
                } else {
                    throw $ex;
                }
            }
        }
    }
private function handleInsert ( array $ options ) { $ attempt = 0 ; $ metadata = $ this -> pluck ( 'tableMetadata' , $ options , false ) ? : [ ] ; $ autoCreate = $ this -> pluck ( 'autoCreate' , $ options , false ) ? : false ; $ maxRetries = $ this -> pluck ( 'maxRetries' , $ options , false ) ? : self :: MAX_RETRIES ; while ( true ) { try { return $ this -> connection -> insertAllTableData ( $ this -> identity + $ options ) ; } catch ( NotFoundException $ ex ) { if ( $ autoCreate === true && $ attempt <= $ maxRetries ) { if ( ! isset ( $ metadata [ 'schema' ] ) ) { throw new \ InvalidArgumentException ( 'A schema is required when creating a table.' ) ; } $ this -> usleep ( mt_rand ( 1 , self :: INSERT_CREATE_MAX_DELAY_MICROSECONDS ) ) ; try { $ this -> connection -> insertTable ( $ metadata + [ 'projectId' => $ this -> identity [ 'projectId' ] , 'datasetId' => $ this -> identity [ 'datasetId' ] , 'tableReference' => $ this -> identity , 'retries' => 0 ] ) ; } catch ( ConflictException $ ex ) { } catch ( \ Exception $ ex ) { $ retryFunction = $ this -> getRetryFunction ( ) ; if ( ! $ retryFunction ( $ ex ) ) { throw $ ex ; } } $ this -> usleep ( self :: INSERT_CREATE_MAX_DELAY_MICROSECONDS ) ; $ attempt ++ ; } else { throw $ ex ; } } } }
Handles inserting table data and manages custom retry logic in the case
a table needs to be created.

@param array $options Configuration options.
@return array
Handles inserting table data and manages custom retry logic in the case a table needs to be created .