cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Read temporary views in SQL Analytics

Marra
New Contributor III

I'm having issues trying to read temporary views in SQL Analytics module. Ive managed to create temporary views based on a query but I don't know how to read from them? Just using the name of the view returns "Table or view not found".

7 REPLIES 7

-werners-
Esteemed Contributor III

@Daniel Alteborgโ€‹ , Temp views are visible only to the session created and are dropped when the session ends.

I guess that is your issue here.

Marra
New Contributor III

No, I'm actually having issues reading from the view in the same session that created it. Using the same view name I get a table or view not found.

-werners-
Esteemed Contributor III

Strange,

did you create the view as follows:

CREATE TEMPORARY VIEW IF NOT EXISTS view

AS ...

(If you are on community edition this feature might not be available, can't tell.)

Marra
New Contributor III

So this is interesting, I tried to run the CREATE query per your example above:

CREATE TEMPORARY VIEW IF NOT EXISTS view_test AS

select * from ....

But this gave me a exception:

"It is not allowed to define a TEMPORARY view with IF NOT EXISTS"

However, I used a similar query before to create my view:

CREATE OR REPLACE TEMPORARY VIEW view_test AS

select * from ....

This works fine, the query returns: "was successfully executed" but I cant use the view becouse it's not found.

Marra
New Contributor III

I should be able to read the view with "select * from view_test"?

-werners-
Esteemed Contributor III

@Daniel Alteborgโ€‹, hm ok,

https://docs.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-syntax-ddl-create-view

so it should work.

Maybe you do not have the necessary permissions?

Marra
New Contributor III

I havn't been able to resolve the issue. I'm using a admin account in databricks so it should't be a permission issue?

Is there any sample dataset that I can use in sql analytics so that I can try again and share my specific code here?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group