Skip to content

Commit

Permalink
Error if unsupported field index type.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingurney committed Aug 2, 2023
1 parent a4251b8 commit 8ff37f4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions matlab/src/matlab/+arrow/+tabular/Schema.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@

function F = field(obj, idx)
idx = convertCharsToStrings(idx);
% idx must be a positive whole number or field name.
if isstring(idx)
if isnumeric(idx) && idx >= 1
args = struct(Index=int32(idx));
proxyID = obj.Proxy.getFieldByIndex(args);
elseif isstring(idx)
name = idx;
args = struct(Name=name);
proxyID = obj.Proxy.getFieldByName(args);
elseif isnumeric(idx)
args = struct(Index=int32(idx));
proxyID = obj.Proxy.getFieldByIndex(args);
else
error(message("arrow:tabular:schema:UnsupportedFieldIndexType", ...
"Index must be a positive scalar integer or a valid field name."));
end

proxy = libmexclass.proxy.Proxy(Name="arrow.type.proxy.Field", ID=proxyID);
Expand Down

0 comments on commit 8ff37f4

Please sign in to comment.