Class ChTable
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.ch.schema.ChAbstractStatement
org.pgcodekeeper.core.database.ch.schema.ChTable
- All Implemented Interfaces:
IOptionContainer,IRelation,ISearchPath,IStatement,IStatementContainer,ITable,IHashable
- Direct Known Subclasses:
ChTableLog
Represents a ClickHouse table with engine configuration and projections.
Supports ClickHouse-specific features like table engines, projections, and specialized DDL operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(IStatement st) Adds a child statement to this container.voidAdds a column to the table.voidAdds an option to this container.voidaddProjection(String key, String expression) Adds a projection to this table.appendAlterSQL(IStatement newCondition, SQLScript script) Fill script with object changes and return change typevoidappendMoveDataSql(IStatement newCondition, SQLScript script, String tblTmpBareName, List<String> identityCols) Adds commands to the script for move data from the temporary table to the new table, given the identity columns, and a command to delete the temporary table.booleancompare(IStatement obj) This method does not account for nested child PgStatements.booleanDeep part ofAbstractStatement.equals(Object).booleancompareIgnoringColumnOrder(ITable newTable) voidcompareOptions(IOptionContainer newContainer, SQLScript script) Compares options between this container and a new container, generating SQL to update differences.voidcomputeChildrenHash(Hasher hasher) voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.booleancontainsColumn(String name) Checks if a column with the specified name exists.voidfillChildrenList(List<Collection<? extends AbstractStatement>> l) getAlterTable(boolean only) Gets a child statement by name and type.getChildrenByType(DbObjType type) get all children by typeFinds column according to specified columnname.Getter forcolumns.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Gets the value for the specified option.Gets all options for this container.Gets the columns of this relation as name-type pairs.booleanChecks if this container has any clustered indexes or constraints.booleanisRecreated(ITable newTable, ISettings settings) Compares this table with thenewTableto determine if a full table recreation is required.voidvoidMethods 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, fillDescendantsList, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, 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.ISearchPath
getContainingSchema, getDatabase, getSchemaName, toObjectReferenceMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendOwnerSQL, canDrop, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getName, getOwner, getParent, getPrivileges, getQualifiedName, getQuotedName, getQuoter, getRenameCommand, getSeparator, getSQL, getTwin, getTypeName, hasChildren, isLib, isOwned, quote, setComment, setLibName, setLocation, setOwner, shallowCopyMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ITable
getStatementType
-
Constructor Details
-
ChTable
Creates a new ClickHouse table with the specified name.- Parameters:
name- the name of the table
-
-
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
-
isRecreated
Description copied from interface:ITableCompares this table with thenewTableto determine if a full table recreation is required. A full recreation (DROP and CREATE) is needed when the tables differ in ways that cannot be altered using ALTER TABLE statements.- Specified by:
isRecreatedin interfaceITable- Parameters:
newTable- the new table definition to compare againstsettings- application settings that may affect the comparison logic- Returns:
trueif the table requires recreation (DROP and CREATE) rather than being alterable,falseif the changes can be applied via ALTER TABLE
-
getAlterTable
-
compareOptions
Description copied from interface:IOptionContainerCompares options between this container and a new container, generating SQL to update differences.- Specified by:
compareOptionsin interfaceIOptionContainer- Parameters:
newContainer- the new container to compare againstscript- the script to append changes to
-
compareIgnoringColumnOrder
- Specified by:
compareIgnoringColumnOrderin interfaceITable- Parameters:
newTable- new state of the table- Returns:
- true if the tables are identical
-
appendMoveDataSql
public void appendMoveDataSql(IStatement newCondition, SQLScript script, String tblTmpBareName, List<String> identityCols) Description copied from interface:ITableAdds commands to the script for move data from the temporary table to the new table, given the identity columns, and a command to delete the temporary table.- Specified by:
appendMoveDataSqlin interfaceITable
-
addProjection
Adds a projection to this table.- Parameters:
key- the projection nameexpression- the projection expression
-
setEngine
-
setPkExpr
-
fillChildrenList
- Overrides:
fillChildrenListin classAbstractStatement
-
isClustered
public boolean isClustered()Checks if this container has any clustered indexes or constraints. -
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
-
getColumn
Finds column according to specified columnname. -
getColumns
Getter forcolumns. The list cannot be modified.- Specified by:
getColumnsin interfaceITable- Returns:
columns
-
getConstraints
- Specified by:
getConstraintsin interfaceITable
-
getRelationColumns
Description copied from interface:IRelationGets the columns of this relation as name-type pairs.- Specified by:
getRelationColumnsin interfaceIRelation- Returns:
- a stream of column name and type pairs
-
getOptions
Description copied from interface:IOptionContainerGets all options for this container.- Specified by:
getOptionsin interfaceIOptionContainer- Returns:
- a map of option keys to values
-
getOption
Gets the value for the specified option.- Parameters:
option- the option key- Returns:
- the option value, or null if not found
-
addOption
Description copied from interface:IOptionContainerAdds an option to this container.- Specified by:
addOptionin interfaceIOptionContainer- Parameters:
option- the option keyvalue- the option value
-
addColumn
Adds a column to the table.- Parameters:
column- the column to add
-
containsColumn
Checks if a column with the specified name exists.- Parameters:
name- the column name- Returns:
- true if column exists, false otherwise
-
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
-
computeChildrenHash
-
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
-