Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support query templating, not just running. #123

Open
rsyi opened this issue Jan 2, 2021 · 1 comment
Open

Support query templating, not just running. #123

rsyi opened this issue Jan 2, 2021 · 1 comment
Labels
good first issue Good for newcomers python

Comments

@rsyi
Copy link
Owner

rsyi commented Jan 2, 2021

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.
@rsyi rsyi added good first issue Good for newcomers python labels Jan 2, 2021
@pranatishete
Copy link

is this issue available, i would like to give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers python
Projects
None yet
Development

No branches or pull requests

2 participants