Skip to content

Commit

Permalink
fix: simplify sqmlesh bigquery import logic (#2995)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabolol authored Feb 6, 2025
1 parent f74c7a1 commit 60ded0c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions warehouse/metrics_tools/transfer/bq.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,13 @@ async def import_table(
bucket = self._storage_client.bucket(gcs_bucket_name)
blobs = list(bucket.list_blobs(prefix=gcs_prefix))

if len(blobs) == 1 and blobs[0].name == gcs_prefix:
logger.info(f"Importing single file {gcs_path} to {table_id}")
source_uris = [gcs_path]
else:
source_uris = [
f"gs://{gcs_bucket_name}/{blob.name}"
for blob in blobs
if blob.name.endswith(".parquet")
]
if not source_uris:
raise ValueError(f"No parquet files found in GCS path {gcs_path}")

logger.info(
f"Importing {len(source_uris)} files from directory {gcs_path} to {table_id}"
)
source_uris = [f"gs://{gcs_bucket_name}/{blob.name}" for blob in blobs]
if not source_uris:
raise ValueError(f"No files found in GCS path {gcs_path}")

logger.info(
f"Importing {len(source_uris)} files from directory {gcs_path} to {table_id}"
)

job_config = bigquery.LoadJobConfig(
source_format=bigquery.SourceFormat.PARQUET,
Expand Down

0 comments on commit 60ded0c

Please sign in to comment.