JingsongLi commented on code in PR #786:
URL: https://github.com/apache/paimon-rust/pull/786#discussion_r3930321554
##########
crates/paimon/src/spec/types.rs:
##########
@@ -1734,6 +1838,79 @@ pub struct RowType {
fields: Vec<DataField>,
}
+/// Render one row field the way Java `DataField.asSQLString` does: the escaped
+/// name, a space, the field type's SQL string, then `COMMENT '...'` when the
+/// field carries a description. Java also appends `DEFAULT <value>`, which
has no
+/// counterpart on this struct.
+fn write_row_field(f: &mut Formatter<'_>, field: &DataField) ->
std::fmt::Result {
+ write!(
+ f,
+ "{} {}",
+ crate::spec::escape_identifier(field.name()),
Review Comment:
[P2] Quote ROW field names with Java's identifier syntax
This helper does not implement Java `EncodingUtils.escapeIdentifier`: the
Rust function only doubles `"` characters and does not add delimiters, while
Java returns a backtick-wrapped identifier and doubles embedded backticks.
Consequently this renders even `id` as `ROW<id INT>` instead of Java's
backtick-wrapped `id`; names containing spaces or reserved words become
ambiguous, and a name containing a backtick is not escaped at all. That also
means the new Python `field_type()` contract is not the claimed Java
`asSQLString()` for nested rows.
Please use a ROW-specific helper that wraps the name in backticks and
replaces each embedded backtick with two backticks (or deliberately align the
existing helper if all its callers need Java syntax), and update the tests to
cover a normal name, a reserved/space-containing name, and an embedded backtick.
--
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]