Skip to content

Fix: Loading DataFrames and creating temp tables with the Python client / ibis Description - #533

Open
ysa23 wants to merge 2 commits into
goccy:mainfrom
ysa23:fix/load-dataframes-and-temp-tables
Open

ysa23 wants to merge 2 commits into
goccy:mainfrom
ysa23:fix/load-dataframes-and-temp-tables

Conversation

@ysa23

@ysa23 ysa23 commented Nov 2, 2026

Copy link
Copy Markdown

Problem

With the Python client (and ibis on top of it), you can't:

  • Load a DataFrame or JSON rows into a table (load_table_from_dataframe(), load_table_from_json()); it fails with 400 unspecified job configuration query (same symptom as Does the emulator work with Pandas GBQ? #288 );
  • Create a temp table from in-memory data (ibis.memtable + create_table(temp=True)), then use it in a later query. This is the usual "stage the data, then MERGE" pattern.

Root causes

  1. A small upload doesn't report the load job's status. The real API always returns a job status when you submit a job. The emulator already does this for large (resumable) uploads, but not for small ones (multipart). ThePython client reads the missing status as "job not started" and submits the load again as a normal request. The emulator can't handle that request, hence the 400.
  2. A query's hidden result dataset gets an invalid name. The emulator names it after the job id. The Python client's ids are UUIDs with hyphens, but real BigQuery dataset ids can only contain letters, digits and underscores (it uses _<hash>). ibis then looks up its temp tables in that dataset by its quoted name, and fails with dataset ... is not found.

Fix

  • Small uploads now return the job status, like large ones.
  • The hidden dataset gets a valid name: _ plus the job id, with any other character replaced by _.

ysa23 added 2 commits November 2, 2026 18:59
jobs.insert returns a Job whose output-only status is always populated
(see the BigQuery REST reference). The resumable upload path already sets
status.state=DONE, but the multipart path returned the job without it.

google-cloud-bigquery's LoadJob.result() treats a missing state as "not
started" and re-submits the job through the plain jobs.insert endpoint,
which does not accept media uploads, so load_table_from_dataframe() and
load_table_from_json() failed with "unspecified job configuration query"
(see goccy#288).
A query without a destination stores its result in a hidden dataset that
was named after the job id. Job ids may contain '-' (the Python client uses
UUIDs) but BigQuery dataset ids only allow letters, digits and underscores;
real BigQuery names these datasets "_<hash>".

Clients that quote the id (e.g. ibis, which reads query.destination of a
"SELECT 1" as its session dataset and later calls tables.get on temp tables
created there) then fail with "dataset ... is not found". Name the dataset
"_" + the job id with every other character replaced by "_".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant