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

Function-ify SQL queries #4

Open
jordantgh opened this issue May 26, 2023 · 3 comments
Open

Function-ify SQL queries #4

jordantgh opened this issue May 26, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jordantgh
Copy link
Owner

Rewrite the query logic to take columns as arguments, etc.

@jordantgh jordantgh added the enhancement New feature or request label May 26, 2023
@jordantgh jordantgh self-assigned this May 26, 2023
@jordantgh
Copy link
Owner Author

jordantgh commented May 29, 2023

@dianario This is also something you could take a look at if you want to learn a bit of SQL. It should be fairly simple.

Instead of writing

function() {
  dbGetQuery(db, "
  SELECT col1, col2, col3 FROM table;
  ")
}

We can isntead do

function(colnames_vector) {
  dbGetQuery(db, glue::glue("
  SELECT {colnames_vector} FROM table;
  "))
}

This will help make the code easier to change and more transparent in the future, as we can pass in the columns within the pipeline script.

Note this refers to code/process_tables/queries.r

@dianario
Copy link
Collaborator

Does this still need to get done?

@jordantgh
Copy link
Owner Author

Does this still need to get done?

It is something simple to implement if you want to get your feet wet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants