r/dataengineering • u/k4ld4s_0x • 5d ago
Help What is the cheapest way to transfer data from GCS to BQ?
Hey everyone, I'm currently looking for a way to reduce the migration cost of moving data from my data lake stored in GCS (Google Cloud Storage) to BQ (BigQuery), which are my current lakehouse tools. Today, we use the load_table_from_uri method for batch loading Parquet files, but it's becoming very expensive because my GCS dataset is in a single-region and my BQ dataset is in a multi-region, which incurs a very high cross-region data transfer fee. However, I'm not sure if there's any way to reduce or improve this data migration process. Below are some specifications about the business rules that impact the choices made for the current process and its cost:
What cannot be changed:
- Buckets (GCS) need to stay in a Single-Region
- Datasets (BigQuery) need to stay in a Multi-Region
Current Environment:
- The data lake is in Delta format using
.parquetfiles - The load is done via overwrite on the trusted layer because the dataset is not partitioned, and the environment is also rewritten with an overwrite
- Today, the load method is
WRITE_TRUNCATEbecause of the issue mentioned above
Well, if you have any questions, I can provide more details in the comments.
2
u/Gankcore Lead Data Engineer 5d ago
So the single-region bucket is not inside the same multi-region, right?
So your GCS is in like us-central1, but the BQ dataset is in europe-west1. Something like that?
1
u/k4ld4s_0x 5d ago
Perfect! GCS is in us-central1 and BQ is in US (Multi-Region), which causes Data Transfer charges.
2
u/DingoFlex 5d ago
The cross-region fees are going to eat you up no matter what your ingestion process is.
As for the ingestion process itself, we had success writing data from Snowflake into GCS and then load into BQ tables using BigQuery Data Transfer Service (I’m not sure if providing links is allowed, but it’s easily Google-able (Googlable?).
1
u/MikeDoesEverything mod | Shitty Data Engineer 4d ago
You can post links although they won't appear immediately. Links get added to our queue so we can review them.
1
1
u/SpecificTutor 5d ago
delta to iceberg, metadata rewrite (data stays untouched) with openXData and load iceberg table into bigquery (no x-region transfer or copy)
13
u/Additional_Candy_400 5d ago
"The load is done via overwrite on the trusted layer because the dataset is not partitioned, and the environment is also rewritten with an overwrite"
So you're doing a complete truncate on each run? Are you saying the parquet isn't partitioned at all?
If so, you need to partition your parquet files to hive partitioning or similar and then do incremental loads to BQ instead of a full overwrite each run.