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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java:
##########
@@ -207,19 +217,27 @@ public String getComment(boolean escapeQuota) {
      * toSql
      */
     public String toSql() {
+        return toSql("`" + name + "`");
+    }
+
+    /**
+     * Convert this column definition to SQL with a caller-provided column 
name.
+     */
+    public String toSql(String columnNameSql) {

Review Comment:
   [P2] Round-trip nested literal metadata with SQL-mode-aware quoting
   
   `AddColumnOp.toSql()` and `ModifyColumnOp.toSql()` now route path-aware 
definitions through this overload, but it still renders decoded DEFAULT/COMMENT 
values with `SqlUtils.escapeQuota`. In ordinary mode a value such as `C:\\tmp` 
is emitted with a single backslash and `parseStringLiteral` turns `\\t` into a 
tab; under `NO_BACKSLASH_ESCAPES`, an embedded `"` is emitted as `\\"` and 
reparses with an extra backslash. Replaying the rendered ALTER can therefore 
commit a different Iceberg initial default or doc. Please use the 
SQL-mode-aware inverse of `parseStringLiteral` for both literal defaults and 
comments, and add ADD/MODIFY round-trip cases in both modes.



##########
be/src/format_v2/table/iceberg_reader.cpp:
##########
@@ -91,31 +91,14 @@ static Status build_missing_equality_delete_key_expr(const 
format::ColumnDefinit
         return Status::OK();
     }
 
-    Field initial_default;
-    if (table_field.initial_default_value_is_base64 ||
-        table_field.type->get_primitive_type() == TYPE_VARBINARY) {
-        // New FE versions mark every Iceberg UUID/BINARY/FIXED default as 
Base64 regardless of its
-        // Doris mapping. Keep the VARBINARY fallback for scan descriptors 
produced before that
-        // marker existed. Decode before parsing so STRING/CHAR and VARBINARY 
all compare against
-        // the raw bytes stored in equality-delete files.
-        std::string decoded_default;
-        if (!base64_decode(*table_field.initial_default_value, 
&decoded_default)) {
-            return Status::InvalidArgument("Invalid Base64 Iceberg initial 
default for field {}",
-                                           table_field.name);
-        }
-        if (table_field.type->get_primitive_type() == TYPE_VARBINARY) {
-            initial_default = 
Field::create_field<TYPE_VARBINARY>(StringView(decoded_default));
-        } else {
-            
DORIS_CHECK(is_string_type(table_field.type->get_primitive_type()));
-            initial_default = 
Field::create_field<TYPE_STRING>(decoded_default);
-        }
-    } else {
-        // An added field's initial default is its logical value in every 
older data file that lacks
-        // the physical column. FE normalizes the string for the current Doris 
table type.
-        RETURN_IF_ERROR(table_field.type->get_serde()->from_fe_string(
-                *table_field.initial_default_value, initial_default));
-    }
+    ColumnPtr initial_default_column;
+    RETURN_IF_ERROR(doris::iceberg::parse_initial_default(

Review Comment:
   [P1] Resolve nested equality-delete keys before applying defaults
   
   This helper can now parse the propagated initial default, but both 
equality-delete readers still resolve `equality_ids` only among top-level 
fields: v2 scans the top-level delete/data schemas and `root_field.fields`, and 
v1 has the same root-only current-schema lookup. The Iceberg specification 
permits primitive equality keys nested through structs, including optional 
parents. For an old data file missing newly added `s.c DEFAULT 7`, a valid 
equality delete on field ID `s.c` therefore fails with `Can not find field id` 
before this helper is reached instead of comparing against 7. Please resolve 
field IDs recursively and retain the nested projection path for v1/v2, with an 
old-file equality-delete regression.



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