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

added options immedate & replace to eng_SQL #2128

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Commits on May 17, 2022

  1. Update engine.R

    add initial attempt at SQL chunk option immediate
    Anne-Wil committed May 17, 2022
    Configuration menu
    Copy the full SHA
    c8668af View commit details
    Browse the repository at this point in the history

Commits on May 18, 2022

  1. Update engine.R

    Improved handling of options$immediate and additional options$replace - these edits work in a knitr::knit_engines$set( ) style test. 
    
    Immediate = T passes param immediate = T to dbExecute() / dbGetQuery(). Immedate is not implemented for query's with options$max.print set. 
    I can't be sure if options$immediate also works icw options$params - I can't get params to run at all on my server. Passing values from local environment using ?value works however, also icw the immediate option. 
    
    Replace = T adds code to drop an existing temporary table before running the into # statement. I thought this might be handy but leave it to others to decide on whether this is truly needed (I also don't really know if this implementation works on other servers than the one I use).
    I've also included an error message to catch attempted replacement of non-temporary tables but error handling doesn't work yet as expected - when attempting to replace a table with a name not starting with #, the generic server error message appears: ([SQL Server]CREATE TABLE permission denied in database 'DWH'. ) - perhaps someone else will now how to fix, though perhaps we'll not want to implement the replace option at all. 
    
    Example code: 
    ```{r qvalue}
    StadiumCode <- '0A'
    ```
    
    
    ```{sql, immediate = T, replace = T}
    SELECT  * 
    into #tum
    FROM statistiek.vw_dimStadium
    where StadiumCode = ?StadiumCode
    
    ```
    
    ```{sql fetch}
    SELECT   *
    FROM #tum
    ```
    Anne-Wil committed May 18, 2022
    Configuration menu
    Copy the full SHA
    c0e6a63 View commit details
    Browse the repository at this point in the history
  2. Update engine.R

    Fixed error handling on temporary table check. What a difference a space makes...
    Anne-Wil committed May 18, 2022
    Configuration menu
    Copy the full SHA
    19366f8 View commit details
    Browse the repository at this point in the history

Commits on Jun 14, 2022

  1. Update engine.R

    - added prefixes sql. to immediate and replace options
    - set NULL as default for sql.immediate
    - handling of user input FALSE as well as TRUE for sql.immediate
    - added stop when attempting to replace (sql.replace == T) when not executing immediately (sql.immedate == F) 
    - removed all-whitespaced lines as well as I could 
    
    To be discussed: implement non-passing of parameter immediate when options$sql.immediate is not set.
    Anne-Wil committed Jun 14, 2022
    Configuration menu
    Copy the full SHA
    358d552 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2022

  1. Update engine.R

    Fix regex for lifting temporary table name to replace when sql.replace =T + a correction to the getQuery call with params where  `sql` was used instead of `query`.
    Anne-Wil committed Jun 24, 2022
    Configuration menu
    Copy the full SHA
    a47b771 View commit details
    Browse the repository at this point in the history