Forum Discussion

rpc1235x's avatar
rpc1235x
New Contributor II
12 months ago
Solved

How to output the SQL statement that was executed in Snowflake - Execute pipe?

Hello,

I have designed this pipeline that:

  1. Generate a month range as $date_1 and $date_2
  2. These variables are inserted into a SQL statement in the "Snowflake - Execute" pipe
  3. Then this is inserted into SSMS

I want the filled SQL statement with the variables that was executed successfully and insert into SSMS as well. Example, if the SQL statement is "SELECT * FROM TABLE WHERE date >= $DATE_1 AND date =< $DATE_2" then I want the SQL statement executed which lets say its "SELECT * FROM TABLE WHERE date >= '2024-02-01' AND date=< '2024-02-28'" and insert this into ssms.

Is there any way to create two streams after the "snowflake execute" one for the SQL server bulk load and another one to extract the SQL statement filled with variables or perhaps after the SQL server bulk load?

Thank you!

 

 

  • Hello rpc1235x,

    You can produce the query string in the Datetime Fixer Mapper, and pass it as is to the Snowflake Execute Snap with Pass Through enabled.

    That way you will have the query string in the original attribute downstream.

     

    Regards,

    Aleksandar.

3 Replies

  • SpiroTaleski's avatar
    SpiroTaleski
    Valued Contributor

    rpc1235x 

    After Datetime Fixer Mapper you can add a Copy Snap and downstream Mapper Snap in which you can add the same query from the Snowflake Execute Snap (where dynamically you are passing the both dates). 

  • Hello rpc1235x,

    You can produce the query string in the Datetime Fixer Mapper, and pass it as is to the Snowflake Execute Snap with Pass Through enabled.

    That way you will have the query string in the original attribute downstream.

     

    Regards,

    Aleksandar.

    • rpc1235x's avatar
      rpc1235x
      New Contributor II

      Thank you! I ended up using this solution.

      If it helps others, here is how it looks:

       

      Inside mapper 2, included:

      • $date_1
      • $date_2
      • the query
      • Date.now() for tracking purposes