Class ChSchema
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.ch.schema.ChAbstractStatement
org.pgcodekeeper.core.database.ch.schema.ChSchema
- All Implemented Interfaces:
ISchema,IStatement,IStatementContainer,IHashable
Represents a ClickHouse database schema (database in ClickHouse terms).
Contains tables, views, dictionaries and has an associated engine type.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(IStatement st) Adds a child statement to this container.appendAlterSQL(IStatement newCondition, SQLScript script) Fill script with object changes and return change typebooleancompare(IStatement obj) This method does not account for nested child PgStatements.booleanDeep part ofAbstractStatement.equals(Object).voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.voidfillChildrenList(List<Collection<? extends AbstractStatement>> l) voidfillDescendantsList(List<Collection<? extends AbstractStatement>> l) Gets a child statement by name and type.getChildrenByType(DbObjType type) get all children by typegetConstraintByName(String constraintName) Finds a constraint by name across all tables and views in this schema.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.voidgetDropSQL(SQLScript script, boolean generateExists) Generates DROP SQL for this statement.getIndexByName(String indexName) Finds an index by name across all tables and views in this schema.getRelation(String name) Gets a relation by name.Gets all relations (tables, views, sequences) in this schema.getStatementContainer(String name) Gets a statement container by name.Gets a stream of all statement containers in this schema.voidMethods inherited from class org.pgcodekeeper.core.database.ch.schema.ChAbstractStatement
appendComments, appendOwnerSQL, formatSql, getQuoter, getRenameCommandMethods inherited from class org.pgcodekeeper.core.database.base.schema.AbstractStatement
addDependency, addPrivilege, appendAlterComments, appendPrivileges, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, deepCopy, equals, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSeparator, getSQL, getTwin, hasChildren, hashCode, isLib, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, shallowCopy, toStringMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISchema
getStatementTypeMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendOwnerSQL, canDrop, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getDatabase, getDependencies, getDescendants, getLibName, getLocation, getName, getOwner, getParent, getPrivileges, getQualifiedName, getQuotedName, getQuoter, getRenameCommand, getSeparator, getSQL, getTwin, getTypeName, hasChildren, isLib, isOwned, quote, setComment, setLibName, setLocation, setOwner, shallowCopy, toObjectReference
-
Constructor Details
-
ChSchema
Creates a new ClickHouse schema with the specified name.- Parameters:
name- the name of the schema
-
-
Method Details
-
getCreationSQL
Description copied from interface:IStatementGenerates 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:
getCreationSQLin interfaceIStatement- Parameters:
script- the SQL script to append creation statements to
-
appendAlterSQL
Description copied from interface:IStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin interfaceIStatement- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
getDropSQL
Description copied from interface:IStatementGenerates DROP SQL for this statement.- Specified by:
getDropSQLin interfaceIStatement- Overrides:
getDropSQLin classAbstractStatement- Parameters:
script- the SQL script to append the DROP statement togenerateExists- whether to include "IF EXISTS" in the DROP statement
-
setEngine
-
getRelations
Description copied from interface:ISchemaGets all relations (tables, views, sequences) in this schema.- Specified by:
getRelationsin interfaceISchema- Returns:
- a stream of relations
-
fillDescendantsList
- Overrides:
fillDescendantsListin classAbstractStatement
-
fillChildrenList
- Overrides:
fillChildrenListin classAbstractStatement
-
getRelation
Description copied from interface:ISchemaGets a relation by name.- Specified by:
getRelationin interfaceISchema- Parameters:
name- the relation name- Returns:
- the relation with the given name, or null if not found
-
getChild
Description copied from interface:IStatementContainerGets a child statement by name and type.- Specified by:
getChildin interfaceIStatementContainer- Parameters:
name- the name of the child to findtype- the type of the child to find- Returns:
- the child statement, or null if not found
-
getChildrenByType
Description copied from interface:IStatementContainerget all children by type- Specified by:
getChildrenByTypein interfaceIStatementContainer- Parameters:
type- the type of the children- Returns:
- unmodifiable collection of child statement, or empty list
-
addChild
Description copied from interface:IStatementContainerAdds a child statement to this container.- Specified by:
addChildin interfaceIStatementContainer- Parameters:
st- the child statement to add
-
getStatementContainer
Gets a statement container by name.- Specified by:
getStatementContainerin interfaceISchema- Parameters:
name- the name of the container to find- Returns:
- the statement container with the given name, or null if not found
-
getStatementContainers
Gets a stream of all statement containers in this schema.- Returns:
- a stream of statement containers
-
getIndexByName
Finds an index by name across all tables and views in this schema.- Parameters:
indexName- the name of the index to find- Returns:
- the index with the given name, or null if not found
-
getConstraintByName
Finds a constraint by name across all tables and views in this schema.- Parameters:
constraintName- the name of the constraint to find- Returns:
- the constraint with the given name, or null if not found
-
getTable
-
computeHash
Description copied from interface:IHashableComputes the hash of the implementing object using the provided hasher. The implementation should call appropriateputmethods on the hasher for all fields that should contribute to the hash value.- Specified by:
computeHashin interfaceIHashable- Parameters:
hasher- the hasher instance to use for hash computation
-
compare
Description copied from class:AbstractStatementThis method does not account for nested child PgStatements. Shallow version ofAbstractStatement.equals(Object)- Specified by:
comparein interfaceIStatement- Overrides:
comparein classAbstractStatement
-
compareChildren
Description copied from class:AbstractStatementDeep part ofAbstractStatement.equals(Object). Compares all object's child PgStatements for equality.- Overrides:
compareChildrenin classAbstractStatement
-