Skip to content

Commit

Permalink
review change
Browse files Browse the repository at this point in the history
  • Loading branch information
flaming-archer committed Dec 16, 2024
1 parent a2cbba3 commit a6d439d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.List;
import java.util.Set;
import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;
import org.apache.gravitino.exceptions.NoSuchSchemaException;

/** Database operations for ClickHouse. */
public class ClickHouseDatabaseOperations extends JdbcDatabaseOperations {
Expand All @@ -42,18 +41,6 @@ protected Set<String> createSysDatabaseNameSet() {
return ImmutableSet.of("information_schema", "INFORMATION_SCHEMA", "default", "system");
}

@Override
public boolean delete(String databaseName, boolean cascade) {
LOG.info("Beginning to drop database {}", databaseName);
try {
dropDatabase(databaseName, cascade);
LOG.info("Finished dropping database {}", databaseName);
} catch (NoSuchSchemaException e) {
return false;
}
return true;
}

@Override
public List<String> listDatabases() {
List<String> databaseNames = new ArrayList<>();
Expand All @@ -62,13 +49,12 @@ public List<String> listDatabases() {
// causing the following statement to error,
// so here we manually set a system catalog
connection.setCatalog(createSysDatabaseNameSet().iterator().next());
try (Statement statement = connection.createStatement()) {
try (ResultSet resultSet = statement.executeQuery("SHOW DATABASES")) {
while (resultSet.next()) {
String databaseName = resultSet.getString(1);
if (!isSystemDatabase(databaseName)) {
databaseNames.add(databaseName);
}
try (Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SHOW DATABASES")) {
while (resultSet.next()) {
String databaseName = resultSet.getString(1);
if (!isSystemDatabase(databaseName)) {
databaseNames.add(databaseName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ private String addColumnFieldDefinition(TableChange.AddColumn addColumn) {
.append(SPACE);
}

//Append comment if available after default value
// Append comment if available after default value
if (StringUtils.isNotEmpty(addColumn.getComment())) {
columnDefinition.append("COMMENT '").append(addColumn.getComment()).append("' ");
}
Expand Down Expand Up @@ -695,13 +695,13 @@ private String updateColumnTypeFieldDefinition(

private StringBuilder appendColumnDefinition(JdbcColumn column, StringBuilder sqlBuilder) {
// Add Nullable data type
String dataType=typeConverter.fromGravitino(column.dataType());
String dataType = typeConverter.fromGravitino(column.dataType());
if (column.nullable()) {
sqlBuilder.append(SPACE).append("Nullable(").append(dataType).append(")").append(SPACE);
} else {
sqlBuilder.append(SPACE).append(dataType).append(SPACE);
}

// ck no support alter table with set nullable

// Add DEFAULT value if specified
Expand All @@ -713,9 +713,9 @@ private StringBuilder appendColumnDefinition(JdbcColumn column, StringBuilder sq
}

// Add column auto_increment if specified
// if (column.autoIncrement()) {
// sqlBuilder.append(CLICKHOUSE_AUTO_INCREMENT).append(" ");
// }
// if (column.autoIncrement()) {
// sqlBuilder.append(CLICKHOUSE_AUTO_INCREMENT).append(" ");
// }

// Add column comment if specified
if (StringUtils.isNotEmpty(column.comment())) {
Expand Down

0 comments on commit a6d439d

Please sign in to comment.