Databricks Views

maheshwor
New Contributor III

How do we find the definition of View in databricks?

Ryan_Chynoweth
Databricks Employee
Databricks Employee

You can use the extended table description. For example, the following python code will print the current definition of the view:

table_name = ""
df = spark.sql("describe table extended {}".format(table_name))
df.createOrReplaceTempView("view_desription")
 
data = spark.sql(
"""
select data_type 
from view_desription
where col_name = 'View Text'
 
"""
).collect()[0][0]
 
print(data)
 
 

View solution in original post