Operations on top of data warehouse
It's possible to run operations and queries manually from the Blacksmith CLI outside the ETL process.
This can be achieved with the
run operation command, which needs at least two
scopeis the database to connect to.
fileis the SQL file to compile and execute.
In the following example, we run the file located at
directly against the destination registered using the
sqlike under the name
$ blacksmith run operation --scope "destination:sqlike(mypostgres)" \ --file "./operations/demo.sql" Executing operations: -> Executing ./operations/demo.sql... Success!
Running a template directly against your database without knowing the compiled
statement can be dangerous. We strongly advise to first use the
which compiles the SQL file under a new file named
This file is located at the same path than the template one.
If we want to make the same run as the previous one but much more safely, we first
compile the SQL file using the
$ blacksmith run operation --scope "destination:sqlike(mypostgres)" \ --file "./operations/demo.sql" \ --dryrun Compiling operations: -> Compiling ./operations/demo.sql... Writing SQL at ./operations/demo.compiled.sql... Success!
After making sure the output SQL is correct, we can then run the compiled statement instead of the template one:
$ blacksmith run operation --scope "destination:sqlike(mypostgres)" \ --file "./operations/demo.compiled.sql" Executing operations: -> Executing ./operations/demo.compiled.sql... Success!
If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the repository. Once we merge it, the changes will be reflected on the website the next time it is deployed.
Thank you for your contributions!