2

As the Title says, is it able to query object definition of the view in Databricks using SQL, especially for Azure Databricks?

like when using SQL Server, I'm able to query the view definition using function OBJECT_DEFINITION or Stored Procedure sp_helptext to display the SELECT statement within Views.

I'm looking all over the internet, don't find one that explains about this. May be there isn't an option?

thanks.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
tmo
  • 117
  • 2
  • 8

1 Answers1

5

It's maybe not very obvious, but you can use SHOW CREATE TABLE SQL command for that - it works for both tables & views. For example if I have view as following:

create view if not exists tacls.tbl1_view as
select * except(grp) from tacls.tbl1;

then I can get definition with

show create table tacls.tbl1_view

the definition will be in the createtab_stmt column:

enter image description here

Alex Ott
  • 80,552
  • 8
  • 87
  • 132