Class SqlObject

java.lang.Object
dev.frostlake.metastore.SqlObject
All Implemented Interfaces:
Taggable
Direct Known Subclasses:
AggregationPolicy, ComputePool, Contact, Database, DynamicTable, Function, JoinPolicy, MaskingPolicy, MaterializedView, Pipe, Procedure, ProjectionPolicy, RowAccessPolicy, Schema, Stage, Table, Tag, View

public abstract class SqlObject extends Object implements Taggable
Abstract base class for SQL database objects Provides common properties and behavior for objects like databases, schemas, tables, views, etc.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
    protected final Instant
     
    protected String
     
    protected String
    Owning role; defaults to SYSADMIN until stamped with the creating role at CREATE time.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructor for SQL objects
    protected
    SqlObject(String name, Instant createdTime)
    Constructor with explicit creation time (for testing or deserialization)
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Get the comment associated with this SQL object
    Get the creation timestamp of this SQL object
    Get the name of this SQL object
    abstract String
    Get the type of this SQL object (e.g., "TABLE", "VIEW", "DATABASE") Subclasses should override to provide their specific type
    Get the owning role of this SQL object
    The value of the named tag on this object, or null if not set.
    All tag associations on this object (tag name -> value).
    int
     
    void
    rename(String newName)
    Rename this SQL object Note: Subclasses may override to add validation or mark as unsupported
    void
    setComment(String comment)
    Set or update the comment for this SQL object
    void
    Rename this object (the catalog/schema map re-keying is the caller's responsibility).
    void
    Set the owning role for this SQL object (stamped with the creating role at CREATE time)
    void
    setTag(String tagName, String value)
    Associate (or overwrite) a tag value on this object; tagName is the canonical upper-cased tag name.
     
    void
    unsetTag(String tagName)
    Remove a tag association from this object (no-op if absent).
    static String
    A stored SQL text without its trailing semicolon, for embedding into a reconstructed CREATE OR REPLACE statement (GET_DDL, VIEW_DEFINITION, SHOW ... text).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      protected String name
    • createdTime

      protected final Instant createdTime
    • comment

      protected String comment
    • owner

      protected String owner
      Owning role; defaults to SYSADMIN until stamped with the creating role at CREATE time.
  • Constructor Details

    • SqlObject

      protected SqlObject(String name)
      Constructor for SQL objects
      Parameters:
      name - The name of the object (will be stored as-is, normalization is subclass responsibility)
    • SqlObject

      protected SqlObject(String name, Instant createdTime)
      Constructor with explicit creation time (for testing or deserialization)
      Parameters:
      name - The name of the object
      createdTime - The creation timestamp
  • Method Details

    • getName

      public String getName()
      Get the name of this SQL object
      Returns:
      The object name
    • setName

      public void setName(String name)
      Rename this object (the catalog/schema map re-keying is the caller's responsibility).
    • getCreatedTime

      public Instant getCreatedTime()
      Get the creation timestamp of this SQL object
      Returns:
      The instant when this object was created
    • getComment

      public String getComment()
      Get the comment associated with this SQL object
      Returns:
      The comment, or null if no comment is set
    • setComment

      public void setComment(String comment)
      Set or update the comment for this SQL object
      Parameters:
      comment - The comment text
    • getOwner

      public String getOwner()
      Get the owning role of this SQL object
      Returns:
      The owner role name (defaults to SYSADMIN)
    • setOwner

      public void setOwner(String owner)
      Set the owning role for this SQL object (stamped with the creating role at CREATE time)
      Parameters:
      owner - The owner role name
    • setTag

      public void setTag(String tagName, String value)
      Description copied from interface: Taggable
      Associate (or overwrite) a tag value on this object; tagName is the canonical upper-cased tag name.
      Specified by:
      setTag in interface Taggable
    • unsetTag

      public void unsetTag(String tagName)
      Description copied from interface: Taggable
      Remove a tag association from this object (no-op if absent).
      Specified by:
      unsetTag in interface Taggable
    • getTagValue

      public String getTagValue(String tagName)
      Description copied from interface: Taggable
      The value of the named tag on this object, or null if not set.
      Specified by:
      getTagValue in interface Taggable
    • getTagValues

      public Map<String,String> getTagValues()
      Description copied from interface: Taggable
      All tag associations on this object (tag name -> value). Named getTagValues to avoid clashing with Schema.getTags().
      Specified by:
      getTagValues in interface Taggable
    • rename

      public void rename(String newName)
      Rename this SQL object Note: Subclasses may override to add validation or mark as unsupported
      Parameters:
      newName - The new name for the object
    • getObjectType

      public abstract String getObjectType()
      Get the type of this SQL object (e.g., "TABLE", "VIEW", "DATABASE") Subclasses should override to provide their specific type
      Returns:
      The object type as a string
    • withoutTrailingSemicolon

      public static String withoutTrailingSemicolon(String sql)
      A stored SQL text without its trailing semicolon, for embedding into a reconstructed CREATE OR REPLACE statement (GET_DDL, VIEW_DEFINITION, SHOW ... text).
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object