Skip to content

Commit

Permalink
[Hotfix][Connector] Fix jdbc compile error (apache#7359)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailin0 authored Aug 10, 2024
1 parent 3130ae0 commit 2769ed5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ protected Column buildColumn(ResultSet resultSet) throws SQLException {
}

@Override
protected String getCreateTableSql(TablePath tablePath, CatalogTable table) {
return OceanBaseMysqlCreateTableSqlBuilder.builder(tablePath, table, typeConverter)
protected String getCreateTableSql(
TablePath tablePath, CatalogTable table, boolean createIndex) {
return OceanBaseMysqlCreateTableSqlBuilder.builder(
tablePath, table, typeConverter, createIndex)
.build(table.getCatalogName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,29 @@ public class OceanBaseMysqlCreateTableSqlBuilder {
private String fieldIde;

private final OceanBaseMySqlTypeConverter typeConverter;
private boolean createIndex;

private OceanBaseMysqlCreateTableSqlBuilder(
String tableName, OceanBaseMySqlTypeConverter typeConverter) {
String tableName, OceanBaseMySqlTypeConverter typeConverter, boolean createIndex) {
checkNotNull(tableName, "tableName must not be null");
this.tableName = tableName;
this.typeConverter = typeConverter;
this.createIndex = createIndex;
}

public static OceanBaseMysqlCreateTableSqlBuilder builder(
TablePath tablePath,
CatalogTable catalogTable,
OceanBaseMySqlTypeConverter typeConverter) {
OceanBaseMySqlTypeConverter typeConverter,
boolean createIndex) {
checkNotNull(tablePath, "tablePath must not be null");
checkNotNull(catalogTable, "catalogTable must not be null");

TableSchema tableSchema = catalogTable.getTableSchema();
checkNotNull(tableSchema, "tableSchema must not be null");

return new OceanBaseMysqlCreateTableSqlBuilder(tablePath.getTableName(), typeConverter)
return new OceanBaseMysqlCreateTableSqlBuilder(
tablePath.getTableName(), typeConverter, createIndex)
.comment(catalogTable.getComment())
// todo: set charset and collate
.engine(null)
Expand Down Expand Up @@ -158,10 +162,10 @@ private String buildColumnsIdentifySql(String catalogName) {
for (Column column : columns) {
columnSqls.add("\t" + buildColumnIdentifySql(column, catalogName, columnTypeMap));
}
if (primaryKey != null) {
if (createIndex && primaryKey != null) {
columnSqls.add("\t" + buildPrimaryKeySql());
}
if (CollectionUtils.isNotEmpty(constraintKeys)) {
if (createIndex && CollectionUtils.isNotEmpty(constraintKeys)) {
for (ConstraintKey constraintKey : constraintKeys) {
if (StringUtils.isBlank(constraintKey.getConstraintName())) {
continue;
Expand Down

0 comments on commit 2769ed5

Please sign in to comment.