コード例 #1
0
  def testJobErrors(self):
    poller = command_utils.BqJobPoller(self.job_service, self.client.tables)
    job_ref = self.MakeJobReference()

    self.ExpectJob(job_ref, 'COPY', error_msg='FAILED COPY')
    with self.assertRaisesRegexp(waiter.OperationError, r'FAILED COPY'):
      waiter.WaitFor(poller=poller, operation_ref=job_ref,
                     message='COPYING TABLE')
      self.AssertOutputEquals('')
      self.AssertErrContains('FAILURE')
コード例 #2
0
  def testOther(self):
    poller = command_utils.BqJobPoller(self.job_service, self.client.jobs)
    job_ref = self.MakeJobReference()

    expected = self.ExpectJob(job_ref, 'OTHER')
    actual = waiter.WaitFor(poller=poller,
                            operation_ref=job_ref,
                            message='OTHER JOB')
    self.assertEqual(expected, actual)
    self.AssertOutputEquals('')
    self.AssertErrContains('OTHER JOB')
コード例 #3
0
  def testLoad(self):
    poller = command_utils.BqJobPoller(self.job_service, self.client.tables)
    job_ref = self.MakeJobReference()

    expected = self.ExpectJob(job_ref, 'LOAD')
    actual = waiter.WaitFor(poller=poller,
                            operation_ref=job_ref,
                            message='LOADING TABLE')
    self.assertEqual(expected, actual)
    self.AssertOutputEquals('')
    self.AssertErrContains('LOADING TABLE')
コード例 #4
0
ファイル: copy.py プロジェクト: camidagreat/music_game_poc
    def Run(self, args):
        job_id = hooks.JobIdProcessor(args.job_id)
        requests_type = hooks.GetApiMessage('BigqueryJobsInsertRequest')
        request = requests_type()
        project = args.project or properties.VALUES.core.project.Get(
            required=True)
        request.projectId = project
        request = hooks.ProcessTableCopyConfiguration(None, args, request)
        request = hooks.ProcessTableCopyOverwrite(None, args, request)
        arg_utils.SetFieldInMessage(request, 'job.jobReference.jobId', job_id)
        arg_utils.SetFieldInMessage(request, 'job.jobReference.projectId',
                                    project)

        client = hooks.GetApiClient()
        job_service = client.jobs
        job = client.jobs.Insert(request)

        source_ref = args.CONCEPTS.source.Parse()
        destination_ref = args.CONCEPTS.destination.Parse()
        copy_message = 'Copying {0}:{1} to {2}:{3}.'.format(
            source_ref.Parent().Name(), source_ref.Name(),
            destination_ref.Parent().Name(), destination_ref.Name())

        if not args. async:
            log.CreatedResource(job.id, kind='Job', details=copy_message)
            return job

        result_service = client.tables
        poller = command_utils.BqJobPoller(job_service, result_service)
        job_ref = resources.REGISTRY.Parse(job.jobReference.jobId,
                                           params={'projectId': project},
                                           collection='bigquery.jobs')
        result = waiter.WaitFor(poller=poller,
                                operation_ref=job_ref,
                                message=copy_message)

        log.status.Print('Copied {0}:{1} to {2}:{3}.'.format(
            source_ref.Parent().Name(), source_ref.Name(),
            destination_ref.Parent().Name(), destination_ref.Name()))
        return result