HeartLinked commented on code in PR #194: URL: https://github.com/apache/iceberg-cpp/pull/194#discussion_r2303232447
########## src/iceberg/type.cc: ########## @@ -105,23 +149,29 @@ std::string ListType::ToString() const { return repr; } std::span<const SchemaField> ListType::fields() const { return {&element_, 1}; } -std::optional<std::reference_wrapper<const SchemaField>> ListType::GetFieldById( +Result<std::optional<std::reference_wrapper<const SchemaField>>> ListType::GetFieldById( int32_t field_id) const { if (field_id == element_.field_id()) { return std::cref(element_); } return std::nullopt; } -std::optional<std::reference_wrapper<const SchemaField>> ListType::GetFieldByIndex( - int index) const { +Result<std::optional<std::reference_wrapper<const SchemaField>>> +ListType::GetFieldByIndex(int index) const { if (index == 0) { return std::cref(element_); } return std::nullopt; } -std::optional<std::reference_wrapper<const SchemaField>> ListType::GetFieldByName( - std::string_view name) const { - if (name == element_.name()) { +Result<std::optional<std::reference_wrapper<const SchemaField>>> ListType::GetFieldByName( + std::string_view name, bool case_sensitive) const { + if (case_sensitive) { + if (name == element_.name()) { + return std::cref(element_); + } + return std::nullopt; + } + if (StringUtils::ToLower(name) == StringUtils::ToLower(element_.name())) { Review Comment: I have one suggestion regarding its scope. I believe the case-insensitive logic should apply exclusively to StructType and not to ListType or MapType. The reason is that the internal field names for ListType ("element") and MapType ("key", "value") are defined by the Iceberg specification as structural components, rather than user-defined columns. As such, they should probably be treated as case-sensitive constants. Look for iceberg Java implementation `TypeUtil.java` and `Type.java`, you'll find there is only `indexByLowerCaseName` functions for StructType. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org