Class View

java.lang.Object
dev.frostlake.metastore.SqlObject
dev.frostlake.metastore.model.View
All Implemented Interfaces:
Taggable

public class View extends SqlObject
  • Constructor Details

  • Method Details

    • getDefinition

      public String getDefinition()
    • getOriginalDdl

      public String getOriginalDdl()
    • setOriginalDdl

      public void setOriginalDdl(String originalDdl)
    • getColumnNames

      public List<String> getColumnNames()
    • hasExplicitColumnNames

      public boolean hasExplicitColumnNames()
    • getResolvedColumns

      public List<TableColumn> getResolvedColumns()
      The view's columns — name and declared type — as its defining query resolved to at CREATE time, or null when they could not be resolved (a body that would not plan, or a snapshot predating capture). This is what INFORMATION_SCHEMA.COLUMNS reports for the view, and through it what DatabaseMetaData.getColumns answers.

      Resolved ONCE, at creation, and never recomputed — which is Snowflake's own behavior, verified live on a real account. There, a view's reported column metadata is a snapshot taken when the view is created and is entirely independent of the tables underneath it afterwards:

      • ALTER TABLE t ALTER COLUMN c SET DATA TYPE VARCHAR(50) leaves every view over c still reporting VARCHAR(10);
      • ALTER TABLE t ADD COLUMN does not widen a SELECT * view — the star was expanded once, at creation;
      • ALTER TABLE t ALTER COLUMN c DROP NOT NULL leaves the view still reporting IS_NULLABLE = NO;
      • dropping the column a view projects — or the whole base table — leaves the view reporting its columns unchanged, even though selecting from it then fails to compile.

      Freezing at creation is also what keeps a metadata read from ever planning a query: INFORMATION_SCHEMA is itself served by these views, so resolving a view body while answering a metadata call could re-enter the metadata layer. Nothing here can.

    • setResolvedColumns

      public void setResolvedColumns(List<TableColumn> resolvedColumns)
    • hasResolvedColumns

      public boolean hasResolvedColumns()
    • isSecure

      public boolean isSecure()
    • setSecure

      public void setSecure(boolean secure)
    • isTemporary

      public boolean isTemporary()
      A TEMPORARY (TEMP / VOLATILE) view lives only as long as the session that created it, the same lifetime Frostlake gives a temporary table. Live also makes it invisible to other sessions and lets it shadow a permanent object of the same name; Frostlake has one namespace per catalog, so it models the lifetime and not the isolation.
    • setTemporary

      public void setTemporary(boolean temporary)
    • getRowAccessPolicyName

      public String getRowAccessPolicyName()
    • setRowAccessPolicyName

      public void setRowAccessPolicyName(String name)
    • getRowAccessPolicyColumns

      public List<String> getRowAccessPolicyColumns()
    • setRowAccessPolicyColumns

      public void setRowAccessPolicyColumns(List<String> cols)
    • hasRowAccessPolicy

      public boolean hasRowAccessPolicy()
    • copy

      public View copy()
      A full-fidelity duplicate for CLONE DATABASE/SCHEMA: keeps the explicit column list, the SECURE flag, the comment and any attached row access policy (the name-and-definition constructor alone silently dropped all of these from clones).
    • ddl

      public String ddl(String displayName)
      The view's full CREATE OR REPLACE statement rendered against displayName (bare for GET_DDL's default output, schema-qualified for the metadata views). Snowflake surfaces a view's executable DDL — not just its query — in INFORMATION_SCHEMA.VIEWS.VIEW_DEFINITION and in SHOW VIEWS' text column; deployment tooling relies on EXECUTE IMMEDIATE of that text to recreate views.
    • getObjectType

      public String getObjectType()
      Description copied from class: SqlObject
      Get the type of this SQL object (e.g., "TABLE", "VIEW", "DATABASE") Subclasses should override to provide their specific type
      Specified by:
      getObjectType in class SqlObject
      Returns:
      The object type as a string