vthemelis commented on code in PR #44633:
URL: https://github.com/apache/arrow/pull/44633#discussion_r1847385598
##########
csharp/src/Apache.Arrow/Schema.cs:
##########
@@ -80,15 +79,20 @@ public int GetFieldIndex(string name, StringComparer
comparer)
public int GetFieldIndex(string name, IEqualityComparer<string>
comparer = default)
{
- comparer ??= StringComparer.CurrentCulture;
+ if (comparer == null ||
comparer.Equals(StringComparer.CurrentCulture))
+ {
+ return _fieldsIndexLookup[name].First();
+ }
- for (int i = 0; i < _fieldsList.Count; i++)
+ for (var i = 0; i < _fieldsList.Count; ++i)
{
if (comparer.Equals(_fieldsList[i].Name, name))
+ {
return i;
+ }
}
- return -1;
+ throw new InvalidOperationException();
Review Comment:
This is actually fixing a regression that was added in
https://github.com/apache/arrow/pull/44576
The function would previously throw `InvalidOperationException` due to
`.First(...)`.
I noticed this because I wrote my unit tests before that PR was merged. Are
you happy with keeping the `return -1` 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]