Skip to content

Commit 20cdc15

Browse files
authored
Data: Add TypeInfo method to Frame (#641)
TypeInfo returns the FrameType and FrameTypeVersion from the frame's metadata
1 parent e018934 commit 20cdc15

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

data/frame.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,3 +550,14 @@ func (f *Frame) FieldByName(fieldName string) (*Field, int) {
550550
}
551551
return nil, -1
552552
}
553+
554+
// TypeInfo returns the FrameType and FrameTypeVersion from the frame's
555+
// Meta.Type and Meta.TypeVersion properties. If either of those properties
556+
// are absent, the corresponding zero value (FrameTypeUnknown and FrameTypeVersion{0,0})
557+
// is returned per each missing property.
558+
func (f *Frame) TypeInfo(fieldName string) (FrameType, FrameTypeVersion) {
559+
if f == nil || f.Meta == nil {
560+
return FrameTypeUnknown, FrameTypeVersion{}
561+
}
562+
return f.Meta.Type, f.Meta.TypeVersion
563+
}

0 commit comments

Comments
 (0)