1 Reply Latest reply on Feb 10, 2018 4:53 AM by Yuriy Fal

    Write back to amazon redshift using r

    Vaibhav Luthra



      I have a requirement of using r code and writing back values of tableau parameters to database. I am using below code for this purpose.

      Given code works perfectly fine on R, however, tableau throws popup of start time to run the table calculation and never ends(waited for 10 mins max).

      Below is my code, please suggest what is causing issue and how this can be resolved.





      driver <- JDBC('com.amazon.redshift.jdbc41.Driver', 'RedshiftJDBC41-', identifier.quote='`');

      url <- 'jdbc:redshift://aws-a0036-use1-1b-d-red-shrd-chb-dev01.cnnhjxs6xgos.us-east-1.redshift.amazonaws.com:5439/test?user=test&password=test';

      conn <- dbConnect(driver, url);

      dbSendQuery(conn, 'insert into test.r_test values(.arg1);')


      MAX([R Param]))

        • 1. Re: Write back to amazon redshift using r
          Yuriy Fal

          Hi Vaibhav,


          Two fine points:


          1) Since the MAX([R Param]) aggregation

          gives a single value as a result,

          you may want to use .arg1[1] in your script.

          This tells R to read just a first value from a vector.


          2) Your SCRIPT_INT() is a Table Calculation in Tableau.

          So it has it's own Addressing & Partitioning logic.


          Tableau sends as many vectors to R

          as the number of partitions in the calc.


          Please check the Edit Table Calculation

          dialog for your SCRIPT_INT() Pill on a view.

          Please make sure all Dimensions are selected

          (under Specific Dimensions dialog option),

          so all Marks on a view would become a single partition.


          Hope it could help.