Class ChSchema

All Implemented Interfaces:
IHashable, ISchema, IStatement, IStatementContainer

public final class ChSchema extends AbstractSchema
Represents a ClickHouse database schema (database in ClickHouse terms). Contains tables, views, dictionaries and has an associated engine type.
  • Constructor Details

    • ChSchema

      public ChSchema(String name)
      Creates a new ClickHouse schema with the specified name.
      Parameters:
      name - the name of the schema
  • Method Details

    • setEngine

      public void setEngine(String engine)
    • getRelations

      public Stream<IRelation> getRelations()
      Description copied from interface: ISchema
      Gets all relations (tables, views, sequences) in this schema.
      Specified by:
      getRelations in interface ISchema
      Overrides:
      getRelations in class AbstractSchema
      Returns:
      a stream of relations
    • getRelation

      public IRelation getRelation(String name)
      Description copied from interface: ISchema
      Gets a relation by name.
      Specified by:
      getRelation in interface ISchema
      Overrides:
      getRelation in class AbstractSchema
      Parameters:
      name - the relation name
      Returns:
      found relation or null if no such relation has been found
    • getChild

      public PgStatement getChild(String name, DbObjType type)
      Description copied from interface: IStatementContainer
      Gets a child statement by name and type.
      Specified by:
      getChild in interface IStatementContainer
      Overrides:
      getChild in class AbstractSchema
      Parameters:
      name - the name of the child to find
      type - the type of the child to find
      Returns:
      the child statement, or null if not found
    • addChild

      public void addChild(IStatement st)
      Description copied from interface: IStatementContainer
      Adds a child statement to this container.
      Specified by:
      addChild in interface IStatementContainer
      Overrides:
      addChild in class AbstractSchema
      Parameters:
      st - the child statement to add
    • getCreationSQL

      public void getCreationSQL(SQLScript script)
      Description copied from class: PgStatement
      Generates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.
      Specified by:
      getCreationSQL in class PgStatement
      Parameters:
      script - the SQL script to append creation statements to
    • appendAlterSQL

      public ObjectState appendAlterSQL(PgStatement newCondition, SQLScript script)
      Description copied from class: PgStatement
      Fill script with object changes and return change type
      Specified by:
      appendAlterSQL in class PgStatement
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • getDropSQL

      public void getDropSQL(SQLScript script, boolean generateExists)
      Description copied from class: PgStatement
      Generates DROP SQL for this statement.
      Overrides:
      getDropSQL in class PgStatement
      Parameters:
      script - the SQL script to append the DROP statement to
      generateExists - whether to include "IF EXISTS" in the DROP statement
    • getDbType

      public DatabaseType getDbType()
      Overrides:
      getDbType in class PgStatement
    • computeHash

      public void computeHash(Hasher hasher)
      Description copied from interface: IHashable
      Computes the hash of the implementing object using the provided hasher. The implementation should call appropriate put methods on the hasher for all fields that should contribute to the hash value.
      Specified by:
      computeHash in interface IHashable
      Overrides:
      computeHash in class AbstractSchema
      Parameters:
      hasher - the hasher instance to use for hash computation
    • compare

      public boolean compare(PgStatement obj)
      Description copied from class: PgStatement
      This method does not account for nested child PgStatements. Shallow version of PgStatement.equals(Object)
      Overrides:
      compare in class AbstractSchema
    • compareChildren

      public boolean compareChildren(PgStatement obj)
      Description copied from class: PgStatement
      Deep part of PgStatement.equals(Object). Compares all object's child PgStatements for equality.
      Overrides:
      compareChildren in class AbstractSchema
    • appendComments

      public void appendComments(SQLScript script)
      Description copied from class: PgStatement
      Appends comment SQL to the script if this statement has comments.
      Overrides:
      appendComments in class PgStatement
      Parameters:
      script - the SQL script to append comments to