liunaijie commented on code in PR #7738: URL: https://github.com/apache/gravitino/pull/7738#discussion_r2227957669
########## catalogs/catalog-jdbc-starrocks/src/main/java/org/apache/gravitino/catalog/starrocks/operations/StarRocksTableOperations.java: ########## @@ -51,59 +81,514 @@ protected String generateCreateTableSql( Transform[] partitioning, Distribution distribution, Index[] indexes) { - throw new NotImplementedException("To be implemented in the future"); + + StringBuilder sqlBuilder = new StringBuilder(); + sqlBuilder.append(String.format("CREATE TABLE `%s` ( \n", tableName)); + // Add columns + sqlBuilder.append( + Arrays.stream(columns) + .map( + column -> { + StringBuilder columnsSql = new StringBuilder(); + columnsSql + .append(SPACE) + .append(BACK_QUOTE) + .append(column.name()) + .append(BACK_QUOTE); + appendColumnDefinition(column, columnsSql); + return columnsSql.toString(); + }) + .collect(Collectors.joining(",\n"))); + sqlBuilder.append(")\n"); + if (StringUtils.isNotEmpty(comment)) { + comment = StringIdentifier.addToComment(StringIdentifier.DUMMY_ID, comment); + sqlBuilder.append(" COMMENT \"").append(comment).append("\""); + } + + appendPartitionSql(partitioning, columns, sqlBuilder); + addDistributionSql(distribution, sqlBuilder); + addPropertiesSql(properties, sqlBuilder); + + // Return the generated SQL statement + String result = sqlBuilder.toString(); + + LOG.info("Generated create table:{} sql: {}", tableName, result); + return result; + } + + @Override + protected String generateAlterTableSql( + String databaseName, String tableName, TableChange... changes) { + JdbcTable lazyLoadTable = null; + List<String> alterSql = new ArrayList<>(); + List<TableChange.SetProperty> setProperties = new ArrayList<>(); + for (int i = 0; i < changes.length; i++) { + TableChange change = changes[i]; + if (change instanceof TableChange.AddColumn) { Review Comment: <img width="1003" height="731" alt="image" src="https://github.com/user-attachments/assets/c8ccb180-608e-4c23-92b5-2111493b3eac" /> StarRocks only support alert those properties, and it recommand only update 1 properties by 1 time. Do we need check by gravitino or just send to starrocks and let starrocks throw exception. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org