cancel
Showing results for 
Search instead for 
Did you mean: 

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

rpc1235x
New Contributor II

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!

rpc1235x_0-1721676208606.png

 

 

1 ACCEPTED SOLUTION

Aleksandar_A
Contributor III

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.

View solution in original post

3 REPLIES 3

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). 

Aleksandar_A
Contributor III

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.

Thank you! I ended up using this solution.

If it helps others, here is how it looks:

rpc1235x_0-1721938065400.png

 

Inside mapper 2, included:

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