liquibase.ext.databricks.change.vacuumTable.VacuumTableGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-databricks Show documentation
Show all versions of liquibase-databricks Show documentation
Liquibase Extension for Databricks.
The newest version!
package liquibase.ext.databricks.change.vacuumTable;
import liquibase.database.Database;
import liquibase.exception.ValidationErrors;
import liquibase.ext.databricks.database.DatabricksDatabase;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
import liquibase.sqlgenerator.SqlGeneratorChain;
import liquibase.sqlgenerator.core.AbstractSqlGenerator;
public class VacuumTableGenerator extends AbstractSqlGenerator {
//check support for optimizer operation
@Override
public boolean supports(VacuumTableStatement statement, Database database) {
return database instanceof DatabricksDatabase;
}
@Override
public ValidationErrors validate(VacuumTableStatement statement, Database database, SqlGeneratorChain chain){
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", statement.getTableName());
// if retentionHours columns if null, dont add to sql statement - just use defaults
return validationErrors;
}
@Override
public Sql[] generateSql(VacuumTableStatement statement, Database database, SqlGeneratorChain chain) {
StringBuilder sql = new StringBuilder("VACUUM ");
sql.append(database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()));
if (statement.getRetentionHours() != null) {
sql.append(" RETAIN ").append(statement.getRetentionHours().toString()).append(" HOURS ");
}
return new Sql[] { new UnparsedSql(sql.toString()) };
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy