yuqi1129 commented on code in PR #7738:
URL: https://github.com/apache/gravitino/pull/7738#discussion_r2229931992


##########
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:
   > If we implement either a whitelist or property size validation here, the 
code will require corresponding updates with each StarRocks release
   
   We can only support 3.3.x here and add some comments about limited support 
for other versions.
   
   > do we need check by gravitino or just send to starrocks and let starrocks 
throw exception
   
   I believe this is reasonable, and that is the point where it differs from 
Doris. 
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to