GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Calling 'job.begin' on job returned from 'Table.upload_from_file' raises a 400 · Issue #2133 · googleapis/google-cloud-python

Calling 'job.begin' on job returned from 'Table.upload_from_file' raises a 400 #2133

New issue
Copy link
New issue
Copy link
Closed
Closed
Calling 'job.begin' on job returned from 'Table.upload_from_file' raises a 400#2133
Copy link
Assignees
tseaver
Labels
api: bigqueryIssues related to the BigQuery API.

Description

@theacodes
theacodes
opened on Aug 18, 2016
Issue body actions

Trying to load data into bigquery with upload_from_file returns a 400.

Sample code:

def load_data_from_file(dataset_name, table_name, source_file_name):
    bigquery_client = bigquery.Client()
    dataset = bigquery_client.dataset(dataset_name)
    table = dataset.table(table_name)

    # Reload the table to get the schema.
    table.reload()

    with open(source_file_name, 'rb') as source_file:
        # This example uses CSV, but you can use other formats.
        # See https://cloud.google.com/bigquery/loading-data
        job = table.upload_from_file(
            source_file, source_format='text/csv')

    job.begin()

    wait_for_job(job)

    print('Loaded {} rows into {}:{}.'.format(
        job.output_rows, dataset_name, table_name))

Error:

Traceback (most recent call last):
  File "load_data_from_file.py", line 77, in <module>
    args.source_file_anme)
  File "load_data_from_file.py", line 45, in load_data_from_file
    job.begin()
  File "/Users/jonwayne/workspace/python-docs-samples/bigquery/cloud-client/env/lib/python3.4/site-packages/gcloud/bigquery/job.py", line 364, in begin
    method='POST', path=path, data=self._build_resource())
  File "/Users/jonwayne/workspace/python-docs-samples/bigquery/cloud-client/env/lib/python3.4/site-packages/gcloud/connection.py", line 347, in api_request
    error_info=method + ' ' + url)
gcloud.exceptions.BadRequest: 400 Load configuration must specify at least one source URI (POST https://www.googleapis.com/bigquery/v2/projects/python-docs-samples-tests/jobs)

Activity

  1. theacodes
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: bigqueryIssues related to the BigQuery API.
    blocks-docs-samples
    on Aug 18, 2016
  2. tseaver
    added
    fix asap
    on Sep 6, 2016
  3. matheuspatury commented on Sep 13, 2016

    @matheuspatury
    matheuspatury
    on Sep 13, 2016
    More actions

    Any updates on this issue? My project is stuck because of it...

  4. jgeewax commented on Sep 13, 2016

    @jgeewax
    jgeewax
    on Sep 13, 2016
    Contributor
    More actions

    Do we know what the problem is yet ? @tseaver

    /cc @omaray

  5. tseaver
    self-assigned this
    on Sep 13, 2016
  6. tseaver commented on Sep 13, 2016

    @tseaver
    tseaver
    on Sep 13, 2016
    Contributor
    More actions

    There is a workaround: first upload the file to Storage, and then load the table from there. E.g., see this system test.

    I will look into reproducing the issue with a new system test.

    Reacted by Vikram
  7. tseaver
    changed the title [-]bigquery.table.Table.upload_from_file fails with 400[/-] [+]Calling 'job.begin' on job returned from Table.upload_from_file[/+] on Sep 14, 2016
  8. tseaver
    changed the title [-]Calling 'job.begin' on job returned from Table.upload_from_file[/-] [+]Calling 'job.begin' on job returned from 'Table.upload_from_file' raises a 400[/+] on Sep 14, 2016
  9. tseaver commented on Sep 14, 2016

    @tseaver
    tseaver
    on Sep 14, 2016
    Contributor
    More actions

    @jonparrott, @matheuspatury Note that it is an error to call job.begin(), because the job returned from table.upload_from_file is a) already started, and b) lacks information needed to start (the error it reports). #2313 shows that the job completes fine without that call.

  10. theacodes commented on Sep 14, 2016

    @theacodes
    theacodes
    on Sep 14, 2016
    ContributorAuthor
    More actions

    Strange, why does the API start this job for you but doesn't do so for
    other things? We should be consistent.

    On Tue, Sep 13, 2016, 5:50 PM Tres Seaver [email protected] wrote:

    @jonparrott https://github.com/jonparrott, @matheuspatury
    https://github.com/matheuspatury Note that it is an error to call
    job.begin(), because the job returned from table.upload_from_file is a)
    already started, and b) lacks information needed to start (the error it
    reports). #2313
    #2313
    shows that the job completes fine without that call.

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub
    #2133 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/AAPUc7bYLzz5uqVntzL3yOryx2uHTcFCks5qp0TlgaJpZM4Jn6R-
    .

  11. tseaver
    added
    docs
    and removed
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    fix asap
    on Sep 14, 2016
  12. tseaver commented on Sep 14, 2016

    @tseaver
    tseaver
    on Sep 14, 2016
    Contributor
    More actions

    In this mode, we start by uploading a file: the back-end spools the uploaded file off somewhere in secret, and has begun to process it before ever returning to the client. Other jobs are created locally on the client first. Given how the back-end works, the only way to be "consistent" would be to remove this feature, and require that users upload files to Storage before loading them.

    We could raise a more informative error from Job.begin if we could detect this case (self.state != None would do it), or we could make it a no-op instead.

  13. theacodes commented on Sep 14, 2016

    @theacodes
    theacodes
    on Sep 14, 2016
    ContributorAuthor
    More actions

    Weird.

    An informative error from begin would be okay with me, as long as there isn't strong feelings that it should no-op.

    It would also be nice to update the docstring to indicate that the job is already started.

  14. tseaver
    closed this as completedin #2313on Sep 15, 2016
  15. tseaver
    added a commit that references this issue on Sep 15, 2016

    Add a system test for 'Table.upload_from_file'. (#2313)

    This issue will close once commit d861610 is merged into the 'main' branch.
    d861610
  16. Etiennepi commented on Nov 30, 2016

    @Etiennepi
    Etiennepi
    on Nov 30, 2016
    More actions

    Note that it is an error to call job.begin()

    Might want to edit the example at https://cloud.google.com/bigquery/loading-data-post-request#bigquery-import-file-python then, as it's telling us to do exactly that when uloading a file from a local machine.

  17. tseaver commented on Nov 30, 2016

    @tseaver
    tseaver
    on Nov 30, 2016
    Contributor
    More actions

    @jonparrott Can you fix that snippet?

  18. theacodes commented on Nov 30, 2016

    @theacodes
    theacodes
    on Nov 30, 2016
    ContributorAuthor
    More actions

    Weird, that snippet is tested. Did we make begin() idempotent?

  19. theacodes commented on Nov 30, 2016

    @theacodes
    theacodes
    on Nov 30, 2016
    ContributorAuthor
    More actions

    Nevermind, I see. I had the test marked as xfail. Fixing now. Thanks!

  20. parthea
    added a commit that references this issue on Nov 24, 2025

    fix: resolve issue where explicit routing metadata was not sent in as…

    2ca283e
  21. parthea
    added a commit that references this issue on Mar 6, 2026

    deps: Remove Python 3.7 and 3.8 as supported runtimes (#2133)

    780b46c
  22. parthea
    added 2 commits that reference this issue on Apr 1, 2026

    fix: Fix row count local execution bug (#2133)

    9a74ab1

    feat: add output_schema parameter to ai.generate() (#2139)

    ae5e5d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.