1

We wanted to create snowflake temp table in databricks. Well temp table gets created but when we try to access it it says the table does note exist.

We checked snowflake history and saw the temp table being created but other query for access is having different session id so the table is lost.

We tried to run multiple statement within sparkqueryrunner but that failed.

I am not able to load screen shot here.

Any solution to this will be appreciated.

Koushur
  • 167
  • 1
  • 9

1 Answers1

1

Temp tables only exist within a session:

Temporary tables only exist within the session in which they were created and persist only for the remainder of the session. As such, they are not visible to other users or sessions. Once the session ends, data stored in the table is purged completely from the system and, therefore, is not recoverable, either by the user who created the table or Snowflake.

An alternative is transient tables:

Transient tables are similar to permanent tables with the key difference that they do not have a Fail-safe period. As a result, transient tables are specifically designed for transitory data that needs to be maintained beyond each session (in contrast to temporary tables), but does not need the same level of data protection and recovery provided by permanent tables.

Felipe Hoffa
  • 54,922
  • 16
  • 151
  • 325
  • Thanks Felipe for the response. My question is more related how to use temp table in data bricks. – Koushur Oct 13 '22 at 23:43
  • 1
    You would have to share code if you want us to comment on your code. In the meantime, use `transient`, not `temp`. Or there might be a better solution, but we can only talk about that if you start by sharing your goals. – Felipe Hoffa Oct 14 '22 at 03:39