Skip to content
Advertisement

Pass/Refer a SQL file in Apache Beam instead of string

I’m trying to run a simple Beam pipeline to extract data from a BQ table using SQL and push to a GCS bucket.

JavaScript

My requirement is to pass the SQL from a file (a simple .sql file) and not as a string. I want to modularize the SQL. So far, I’ve tried the following option – it did not work:

JavaScript

where the contents of my file_query.sql file look like: "SELECT col1, col2, col3 FROM `project.dataset.table`"

Any help on this folks?

Advertisement

Answer

Any information on the failure that you get? I ran almost a copy from what you shared, and it seems to work fine for me.

file_query.sql

JavaScript

pipeline.py

JavaScript

Running the above code is printing rows to the console.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement