Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
To define a view in Python, apply the @temporary_view decorator, then reference views by name in other queries, including materialized views and streaming tables. The results of the view are calculated when queried.
Note
The older dlt module used the @view decorator to defiine a temporary view. Databricks recommends using the pyspark.pipelines module (imported as dp) and the @temporary_view decorator to define temporary views.
Syntax
from pyspark import pipelines as dp
@dp.temporary_view(
name="<name>",
comment="<comment>")
@dp.expect(...)
def <function-name>():
return (<query>)
Parameters
| Parameter | Type | Description |
|---|---|---|
| function | function |
Required. A function that returns an Apache Spark DataFrame or streaming DataFrame from a user-defined query. |
name |
str |
The view name. If not provided, defaults to the function name. The name must be unique within the catalog and schema targeted by the pipeline. |
comment |
str |
A description for the table. |