Class Table

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

public class Table extends SqlObject
  • Constructor Details

  • Method Details

    • getDataRetentionTimeInDays

      public Integer getDataRetentionTimeInDays()
    • setDataRetentionTimeInDays

      public void setDataRetentionTimeInDays(Integer dataRetentionTimeInDays)
    • isCatalogResident

      public boolean isCatalogResident()
      Whether this instance is a real table the catalog holds, as opposed to one of the many derived relations the executor builds and hands round in the same shape — a CTE result, a VALUES list, a subquery, a merged join view, a self-join copy, a stage scan, a table function's output.

      Only a schema registering the table sets this (Schema.addTable), so it answers by IDENTITY and never by name. Asking the catalog to re-resolve the table's bare name instead — what the type channel used to do — silently answered "not a catalog table" for every table reached through a schema-qualified FROM, because a bare name resolves in the session's CURRENT schema: FROM base.t while sitting in PUBLIC resolved nothing, and where PUBLIC happened to hold its own t it resolved the wrong instance. Every column of such a table was then treated as having no declared type, which is why a view over one reported the VARCHAR placeholder for expressions whose type is perfectly well known.

    • getQualifiedName

      public String getQualifiedName()
      The database.schema.table this instance was last resolved under, or null before any query read it — the key its rows are stored by. Re-set on every resolution, so a rename catches up.
    • setQualifiedName

      public void setQualifiedName(String qualifiedName)
    • getRelationStatistics

      public RelationStatistics getRelationStatistics()
      The statistics a derived relation carries of the catalog table beneath it, or null.
    • setRelationStatistics

      public void setRelationStatistics(RelationStatistics relationStatistics)
    • markCatalogResident

      public void markCatalogResident()
      Called by Schema.addTable as the table enters the catalog. One-way on purpose: a dropped table is unreachable from the query path, and a rename re-registers the same instance.
    • getJoinKeyNames

      public List<String> getJoinKeyNames()
      The join-key column names of a USING / NATURAL join's merged relation (upper-cased, in USING-list / left-table order), or null for an ordinary table.
    • setJoinKeyNames

      public void setJoinKeyNames(List<String> joinKeyNames)
    • getJoinedRelations

      public JoinedRelations getJoinedRelations()
      The relations a join's merged relation joins and which of them an outer join extends with NULLs, or null for any other table.
    • setJoinedRelations

      public void setJoinedRelations(JoinedRelations joinedRelations)
    • getColumns

      public List<TableColumn> getColumns()
    • columnCount

      public int columnCount()
      The column count WITHOUT copying the column list (getColumns() copies per call).
    • columnAt

      public TableColumn columnAt(int index)
      The column at a position WITHOUT copying the column list — the per-row write path's accessor.
    • columnsView

      public List<TableColumn> columnsView()
      A read-only LIVE view of the columns for hot paths that only iterate — an ALTER stays visible through it, and nothing is copied. getColumns() keeps returning a defensive copy for callers that hold or mutate their list.
    • hasPrimaryKeyColumns

      public boolean hasPrimaryKeyColumns()
      Whether any PRIMARY KEY columns are declared, without copying the name list.
    • findColumn

      public TableColumn findColumn(String name)
      The column, or null when there is none — for callers that phrase the miss their own way. Resolves exactly as getColumn(java.lang.String) does, through the same index, so the two can never disagree.
    • getColumn

      public TableColumn getColumn(String name)
    • getColumnIndex

      public int getColumnIndex(String name)
    • hasColumn

      public boolean hasColumn(String name)
    • getPrimaryKeys

      public List<String> getPrimaryKeys()
    • getForeignKeys

      public List<ForeignKeyConstraint> getForeignKeys()
    • primaryKeyConstraintName

      public String primaryKeyConstraintName()
      The name of this table's PRIMARY KEY constraint — one constraint however many columns it spans — or null when the table has none: the name an explicit CONSTRAINT <name> PRIMARY KEY gave it (see setPrimaryKeyConstraintName(java.lang.String)), else an auto-generated SYS_CONSTRAINT_<uuid>.
    • setPrimaryKeyConstraintName

      public void setPrimaryKeyConstraintName(String name)
      Record the name an explicit CONSTRAINT <name> PRIMARY KEY declaration gave this table's primary key. A null or blank name changes nothing, leaving the constraint to auto-name itself.
    • uniqueConstraintName

      public String uniqueConstraintName(String columnName)
      The name of the single-column UNIQUE constraint a column-level UNIQUE declares. A column that belongs to a table-level constraint is named by that constraint instead — see getUniqueConstraints().
    • setUniqueConstraintName

      public void setUniqueConstraintName(String columnName, String name)
      Restore a persisted name for the single-column UNIQUE constraint on one column.
    • renameConstraint

      public boolean renameConstraint(String oldName, String newName)
      Move a constraint to a new name — ALTER TABLE … RENAME CONSTRAINT old TO new. A name can live in four places (a declared UNIQUE, the primary key, a table-level FOREIGN KEY, and the per-column name an inline UNIQUE or REFERENCES carries), so all four are searched.
      Returns:
      whether a constraint of that name was found and renamed.
    • constraintColumns

      public List<String> constraintColumns(String constraintName)
      The columns a named constraint covers, or an empty list when no constraint carries that name.
    • setColumnForeignKeyConstraintName

      public void setColumnForeignKeyConstraintName(String columnName, String name)
      Restore a persisted name for the FOREIGN KEY constraint an inline REFERENCES declares.
    • getUniqueConstraints

      public List<UniqueConstraint> getUniqueConstraints()
      Every UNIQUE constraint on this table, ONE entry per constraint (never one per column): the table-level constraints as declared — a UNIQUE (a, b) is a single constraint with a single name — followed by a single-column constraint for every unique column none of them spans, which is what a bare column-level UNIQUE declares.
    • getDeclaredUniqueConstraints

      public List<UniqueConstraint> getDeclaredUniqueConstraints()
      Only the UNIQUE constraints declared at TABLE level, as stored — for persistence and structural copies, which must not turn a column-level UNIQUE into a table-level constraint on reload. Callers reporting metadata want getUniqueConstraints() instead.
    • columnForeignKeyConstraintName

      public String columnForeignKeyConstraintName(String columnName)
      The name of the FOREIGN KEY constraint an inline REFERENCES on one column declares.
    • addForeignKey

      public void addForeignKey(ForeignKeyConstraint foreignKey)
    • dropForeignKey

      public void dropForeignKey(String constraintName)
    • isTemporary

      public boolean isTemporary()
    • isTransient

      public boolean isTransient()
    • isHybrid

      public boolean isHybrid()
    • setHybrid

      public void setHybrid(boolean hybrid)
    • isChangeTracking

      public boolean isChangeTracking()
    • setChangeTracking

      public void setChangeTracking(boolean changeTracking)
    • isReclusterSuspended

      public boolean isReclusterSuspended()
      Whether automatic reclustering is paused — ALTER TABLE … SUSPEND RECLUSTER. SHOW TABLES' automatic_clustering cell reads ON only for a CLUSTERED table that is not suspended.
    • setReclusterSuspended

      public void setReclusterSuspended(boolean reclusterSuspended)
    • isSchemaEvolution

      public boolean isSchemaEvolution()
      ENABLE_SCHEMA_EVOLUTION — SHOW TABLES reports it as Y/N (live-verified).
    • setSchemaEvolution

      public void setSchemaEvolution(boolean schemaEvolution)
    • getRowCount

      public long getRowCount()
    • setRowCount

      public void setRowCount(long rowCount)
    • getClusterKeys

      public List<String> getClusterKeys()
    • setClusterKeys

      public void setClusterKeys(List<String> clusterKeys)
    • addColumn

      public void addColumn(TableColumn column)
    • dropColumn

      public void dropColumn(String name)
    • addColumn

      public void addColumn(String name, DataType dataType)
    • renameColumn

      public void renameColumn(String oldName, String newName)
    • alterColumnType

      public void alterColumnType(String columnName, DataType newDataType)
    • addPrimaryKeyConstraint

      public void addPrimaryKeyConstraint(List<String> columnNames)
    • dropPrimaryKey

      public void dropPrimaryKey()
    • dropUnique

      public void dropUnique(List<String> columnNames)
    • dropForeignKeyColumns

      public void dropForeignKeyColumns(List<String> columnNames)
    • addUniqueConstraint

      public void addUniqueConstraint(String constraintName, List<String> columnNames)
      Add a UNIQUE constraint spanning one or more columns: flag every column unique (that is how the engine enforces uniqueness) and record the constraint, so its columns stay ONE constraint under ONE name. A null or blank constraintName auto-names it the way Snowflake does.
    • addUniqueConstraint

      public void addUniqueConstraint(UniqueConstraint constraint)
      Add an already-built UNIQUE constraint — the CREATE TABLE parse path and snapshot restore.
    • 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
    • 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()
    • getAggregationPolicyName

      public String getAggregationPolicyName()
    • setAggregationPolicyName

      public void setAggregationPolicyName(String name)
    • hasAggregationPolicy

      public boolean hasAggregationPolicy()
    • getDataMetricSchedule

      public String getDataMetricSchedule()
    • setDataMetricSchedule

      public void setDataMetricSchedule(String schedule)
    • getDataMetrics

      public List<DataMetricAttachment> getDataMetrics()
      The data metric functions attached to this table, in the order they were added.
    • addDataMetric

      public void addDataMetric(DataMetricAttachment attachment)
      Attach a metric unless the same one over the same columns is already there (live: a repeat adds nothing).
    • findDataMetric

      public DataMetricAttachment findDataMetric(String metricName, List<String> columns)
      The attachment for that metric over those columns, or null when there is none.
    • dropDataMetric

      public boolean dropDataMetric(String metricName, List<String> columns)
      Detach that metric; answers whether there was one to detach.
    • getSearchOptimization

      public List<SearchOptimizationExpression> getSearchOptimization()
      The configured search-optimization expressions, in the order they were added.
    • hasSearchOptimization

      public boolean hasSearchOptimization()
    • addSearchOptimization

      public SearchOptimizationExpression addSearchOptimization(String method, String target, String targetDataType)
      Add one expression unless an identical one is already configured — live takes a repeat without adding a second row.
      Returns:
      the expression, whether it was added now or already there
    • restoreSearchOptimization

      public void restoreSearchOptimization(SearchOptimizationExpression expression)
      Restore one expression with the number it already had (snapshot / clone).
    • dropSearchOptimization

      public boolean dropSearchOptimization(int expressionId)
      Drop the expression with that number; answers whether there was one.
    • dropSearchOptimization

      public boolean dropSearchOptimization(String method, String target)
      Drop the expression naming that method and target; answers whether there was one.
    • clearSearchOptimization

      public void clearSearchOptimization()
      Drop the lot — the bare DROP SEARCH OPTIMIZATION.
    • getJoinPolicyName

      public String getJoinPolicyName()
    • setJoinPolicyName

      public void setJoinPolicyName(String name)
    • hasJoinPolicy

      public boolean hasJoinPolicy()
    • getAggregationEntityKey

      public List<String> getAggregationEntityKey()
    • setAggregationEntityKey

      public void setAggregationEntityKey(List<String> columns)
    • getCheckConstraints

      public List<CheckConstraint> getCheckConstraints()
      The CHECK constraints, in declaration order.
    • addCheckConstraint

      public void addCheckConstraint(CheckConstraint check)
    • dropCheckConstraint

      public boolean dropCheckConstraint(String name)
      Remove the check of that name; answers whether there was one.
    • getContacts

      public Map<String,String> getContacts()
      The contacts attached to this table, keyed by purpose.
    • setContact

      public void setContact(String purpose, String contactName)
      Attach a contact for a purpose, replacing whatever that purpose held.
    • unsetContact

      public void unsetContact(String purpose)
      Detach the contact held for a purpose, if any — live does not mind that there was none.