Class View
Object
org.apache.spark.sql.connector.catalog.View
- All Implemented Interfaces:
Relation
A view in a catalog -- the typed payload returned by
ViewCatalog.loadView(org.apache.spark.sql.connector.catalog.Identifier) and accepted
by ViewCatalog.createView(org.apache.spark.sql.connector.catalog.Identifier, org.apache.spark.sql.connector.catalog.View) / ViewCatalog.replaceView(org.apache.spark.sql.connector.catalog.Identifier, org.apache.spark.sql.connector.catalog.View). A View carries the
view-specific fields that cannot be represented as string table properties: the query text,
captured creation-time resolution context, captured SQL configs, schema-binding mode, and
query output column names. Columns and user TBLPROPERTIES are set via the typed builder.
Unlike a Table, a View is itself a Relation rather than something Spark
realizes into a Table: Spark expands the view's query text at read time and never builds
a view object. A RelationCatalog returns a View directly from
RelationCatalog.loadRelation(org.apache.spark.sql.connector.catalog.Identifier) for a view identifier, so it never has to smuggle a view
through the Table surface.
- Since:
- 4.2.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionColumn[]columns()The columns of this relation.The current catalog at the time the view was created, used to resolve unqualified identifiers inqueryText()at read time.String[]The current namespace at the time the view was created, used alongsidecurrentCatalog()to resolve unqualified identifiers inqueryText()at read time.The string map of properties of this relation.String[]Output column names of the query that created the view, used to map the query output to the view's declared columns during view resolution.The SQL text of the view.schema()The view's schema binding mode.The SQL configs captured at view creation time, applied when parsing and analyzing the view body.Returns the structured list of objects this view depends on (source tables and functions), ornullif no dependency list was supplied.
-
Method Details
-
columns
Description copied from interface:RelationThe columns of this relation. -
schema
-
properties
Description copied from interface:RelationThe string map of properties of this relation.- Specified by:
propertiesin interfaceRelation
-
queryText
The SQL text of the view. -
currentCatalog
The current catalog at the time the view was created, used to resolve unqualified identifiers inqueryText()at read time. May benullif the view was created with no captured resolution context. -
currentNamespace
The current namespace at the time the view was created, used alongsidecurrentCatalog()to resolve unqualified identifiers inqueryText()at read time. Nevernull; empty when no namespace was captured. -
sqlConfigs
The SQL configs captured at view creation time, applied when parsing and analyzing the view body. Keys are unprefixed SQL config names (e.g.spark.sql.ansi.enabled). -
schemaMode
The view's schema binding mode. Allowed values match thetoStringform oforg.apache.spark.sql.catalyst.analysis.ViewSchemaMode:BINDING,COMPENSATION,TYPE EVOLUTION,EVOLUTION. May benullwhen schema binding is not configured. -
queryColumnNames
Output column names of the query that created the view, used to map the query output to the view's declared columns during view resolution. Empty for views inEVOLUTIONmode, which always use the view's current schema. -
viewDependencies
Returns the structured list of objects this view depends on (source tables and functions), ornullif no dependency list was supplied. Unlike other view metadata which is encoded intoproperties(), dependency lists are a first-class field because their nested structure does not round-trip cleanly through flat string properties.
-