Currently, our Jinja engine (wh run) combines the templating and execution of the provided query into one step. For pipelining purposes, it could be useful to enable wh render that simply returns the query, without execution.
There are two parts to this issue (for python contributors, feel free to build the python end without building the rust part):
- Python: (The python library lives in the
pipelines sub-directory) We'll need to write a function (perhaps render_sql_file) that takes a file, opens it, then runs whale.utils.template_query on it, returning/logging the final result. The appropriate place for this is in whale.__init__, where the run and execute_sql_file functions already live. template_query does all the hard work already, so this function is just a wrapper, just as execute_sql_file is to the run function (see both for an example of what I mean).
- Python: As-is, the API is just a set of scripts that are executed from a shell by rust, so you'll have to write a script that runs the
whale.render_sql_file function. See pipelines/build_script.py for an example.
- Rust: you'll have to modify
main.rs to create a new subcommand for the CLI, render, and then have this reference a function in lib.rs that sources the whale virtual environment in ~/.whale/libexec. I'd directly just copy over the logic from the pull subcommand or run subcommands, which do the same thing.
Currently, our Jinja engine (
wh run) combines the templating and execution of the provided query into one step. For pipelining purposes, it could be useful to enablewh renderthat simply returns the query, without execution.There are two parts to this issue (for python contributors, feel free to build the python end without building the rust part):
pipelinessub-directory) We'll need to write a function (perhapsrender_sql_file) that takes a file, opens it, then runswhale.utils.template_queryon it, returning/logging the final result. The appropriate place for this is inwhale.__init__, where therunandexecute_sql_filefunctions already live.template_querydoes all the hard work already, so this function is just a wrapper, just asexecute_sql_fileis to therunfunction (see both for an example of what I mean).whale.render_sql_filefunction. Seepipelines/build_script.pyfor an example.main.rsto create a new subcommand for the CLI,render, and then have this reference a function inlib.rsthat sources the whale virtual environment in~/.whale/libexec. I'd directly just copy over the logic from thepullsubcommand orrunsubcommands, which do the same thing.