Reading data from an empty table in snowflake

How can we read an empty table from Snowflake - Select snap?

While I use Snowflake - Select snap and the table is empty, I don’t see any output preview so I decided to write it down to a flat file and the file generated was empty as well. How can I ensure that at least table columns are printed on the flat file as well as the same can be seen on the output preview of the snap too. I’m fine if the data beneath it displays as null.

I’ve nothing to do with the data but it is important for me to record the counts; as this is the first snap and it has no data, the other snaps after this would execute but nothing would happen which is kind of weird to me.

Any help is highly appreciated.

Best Regards,

Hello @darshthakkar.

You can get the output schema by opening the second output view, and if your goal is to proceed with executing downstream even if there are no rows selected you can achieve that by using the Gate Snap and a Router afterwards to route to the corresponding branch.

Please refer to the attached sample pipeline.
-SL-comm-snowflake-select-empty_2023_03_22.slp (12.8 KB)

Hope it helps. :slight_smile:


1 Like

Thank you, @AleksandarAngelevski for sharing this.
I feel like it involves a lot of processing just to record the counts.

I thought of it in the interim and planning to use a snowflake - execute with the query that fetches the counts (as I’m not concerned with the data), once I get that number, I can pass it to the last snap I use for notifying it via an email.

So, it will save me from using different snaps and at the end of the day, I get my desired result. Thanking you again for your help and time on this one.

1 Like

The whole point of reading data from an empty table in snowflake - select snap was to record the counts, as there is no easier way to do that when the table is empty, we can leverage the snowflake - execute snap and modify the query to get the counts ONLY.

Return data type is an integer for me which I don’t have any concern with and, if need be, that can be converted to a String. Thus, the easiest solution is to use a Snowflake - Execute snap instead of a Snowflake - Select and modify the query.

P.S.: All snowflake snaps trying to fetch data in an empty table wouldn’r return anything. Not even Null or 0.

Closing this thread now. Thank you.