Local file load (G2 upload host)¶
Demonstrates client.load_table_from_file(io.BytesIO(...)) against
the emulator's /upload/bigquery/v2/... endpoints.
The script:
- Starts an ephemeral emulator on a random port via the
bqemulator.testing.testcontainershelper (or any existing running instance viaBIGQUERY_EMULATOR_HOST). - Creates a dataset and a
customers (id INT64, name STRING)table. - Uploads a 3-row CSV via the Python client's multipart upload path.
- Queries the rows back and asserts the count is 3.
Run¶
What to look for¶
- The same
LoadJobConfigflags work as against real BigQuery. - The
load_table_from_filecall returns a normalLoadJobobject;job.result()blocks until the load completes. - The upload host routes (
/upload/bigquery/v2/...) are completely transparent to the client — they're an implementation detail of thegoogle-cloud-bigquerylibrary.