Ingest data into Bauplan
Bauplan ingests files that are already on object storage, in a bucket it can read, and turns them into tables. Getting the data there from where it lives (a database, an API, another system) is up to you. The pages in this section show common ways to do it.
This page covers the primitives and the basic import loop. For managed and external tables, see tables and namespaces. For branches and transactions, see catalog and branches.
Pick a primitive
| Primitive | Creates | Copies data | Use it for |
|---|---|---|---|
create_table | An empty managed table, with the schema read from the source files | No | Defining a managed table, once |
import_data | New rows in an existing managed table | Yes, rewritten as Parquet in the warehouse | Loading files into a managed table, repeatedly |
create_external_table_from_parquet | An external table over Parquet files, in place | No | Staging files for a pipeline, or reading files you do not want to copy |
create_external_table_from_metadata | An external table pointing at an Iceberg metadata file | No | Registering Iceberg tables written by other systems |
Each primitive is available in the Python SDK and in the CLI (bauplan table create, bauplan table import, bauplan table create-external).
Managed imports accept Parquet, CSV, newline-delimited JSON (.jsonl) and Avro. External tables accept Parquet only. Files must be on Amazon S3 (s3://) or Google Cloud Storage (gs://), in a location your Bauplan deployment can read.
Create the table once, then import on every run
Both steps write. Run them on a data branch whose name starts with your username, never directly on main:
bauplan branch create <username>.ingest-orders --from-ref main
bauplan table create raw.orders --search-uri 's3://my-bucket/raw/orders/*.parquet' --branch <username>.ingest-orders
bauplan table import raw.orders --search-uri 's3://my-bucket/raw/orders/*.parquet' --branch <username>.ingest-orders
The same in Python:
from datetime import datetime, timezone
import bauplan
client = bauplan.Client()
stamp = datetime.now(timezone.utc).strftime("%Y%m%d%H%M%S")
branch = f"{client.info().user.username}.orders-ingestion-prod-{stamp}"
client.create_branch(branch=branch, from_ref="main")
uri = "s3://my-bucket/raw/orders/*.parquet"
if not client.has_table(table="orders", ref=branch, namespace="raw"):
client.create_table(table="orders", search_uri=uri, branch=branch, namespace="raw")
state = client.import_data(table="orders", search_uri=uri, branch=branch, namespace="raw")
if state.job_status != "SUCCESS":
raise RuntimeError(f"import failed: {state.error}")
create_table reads the schema of the matching files and creates an empty table. If the files disagree on the type of a column, it fails and asks you to resolve the conflict in a table creation plan. See how to control types at import.
import_data does not raise when the import fails. Check the job_status of the state it returns, as above. To wait for a job that runs detached, poll it with Client.get_job.
An import only appends. It lists the files matching the search URI, skips the ones already imported into this table, and adds the rows of the rest. It never replaces the table, overwrites rows, removes a column, retypes a column, or compacts files. Files with a column the table does not have add that column, null for the existing rows. When the source schema changes in other ways, the import does not adapt the table. See how to migrate tables.
The import identifies files by their path only. A file overwritten in place with new content is skipped by the next import, and its new rows never reach the table. Write new data under new object keys.
Every import lists all objects under the search URI, and listing gets slower as the bucket grows. Narrow the URI to the files that can be new, for example the current date prefix. See how to lay out data on object storage.
Each import is a transaction. It runs on a temporary branch and merges into your branch only if it succeeds. You can safely run the same import again, since it adds nothing the second time.
When the import has succeeded and you have checked the result, merge the branch into main and delete it. Use a new branch for the next run. Who and what publishes to main is covered in how to bring data to production.
Replace a table
An import only appends. To replace the contents of a table:
- On a data branch, recreate the table (
create_tablewithreplace=True, or delete it and create it again), import the new files, and merge. The merge replaces the table onmainin one commit. Recreating a table resets its import history, and the next import reads every matching file again. - Register the new files as an external staging table, and write the target table with a pipeline that uses the
REPLACEmaterialization strategy. The staging pattern is shown in stage the new files as an external table.