github-actions[bot] commented on code in PR #63240:
URL: https://github.com/apache/doris/pull/63240#discussion_r3255159231


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergExternalTable.java:
##########
@@ -459,4 +459,52 @@ public boolean hasSortOrder() {
         org.apache.iceberg.SortOrder sortOrder = table.sortOrder();
         return sortOrder != null && !sortOrder.isUnsorted();
     }
+
+    /** Reconstructs PARTITION BY LIST (...) () from the Iceberg PartitionSpec 
for SHOW CREATE TABLE. */
+    public String getPartitionSpecSql() {
+        makeSureInitialized();
+        Table table = getIcebergTable();
+        PartitionSpec spec = table.spec();
+        if (spec == null || spec.isUnpartitioned()) {
+            return "";
+        }
+        List<String> fields = new ArrayList<>();
+        for (PartitionField field : spec.fields()) {
+            String colName = table.schema().findColumnName(field.sourceId());
+            if (colName == null) {
+                continue;
+            }
+            org.apache.iceberg.transforms.Transform<?, ?> t = 
field.transform();
+            // isVoid/isIdentity: public interface methods; toString(): 
canonical spec-defined names.
+            if (t.isVoid()) {
+                continue;
+            } else if (t.isIdentity()) {
+                fields.add(colName);
+            } else {

Review Comment:
   `colName` is emitted raw in this and the transform cases below. Iceberg 
tables can have partition columns that require quoting in Doris SQL, such as a 
reserved name like `select` or a name containing special characters/backticks. 
The table column list in `SHOW CREATE TABLE` is quoted, but this clause would 
generate non-replayable SQL like `PARTITION BY LIST (select) ()` or `BUCKET(16, 
a-b)`. Please format partition column references the same way as other DDL 
output, including backtick quoting and escaping embedded backticks, before 
adding them to `fields`.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to