HeartLinked commented on code in PR #194:
URL: https://github.com/apache/iceberg-cpp/pull/194#discussion_r2303183792
##########
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:
maybe we can simply use `if (StringUtils::ToLower(name) ==
kLowerCaseElementName) {` ?
--
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]