aboutsummaryrefslogtreecommitdiff
path: root/weed/mq/schema/schema.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/mq/schema/schema.go')
-rw-r--r--weed/mq/schema/schema.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/weed/mq/schema/schema.go b/weed/mq/schema/schema.go
index 5fadf2cc2..ca31ce534 100644
--- a/weed/mq/schema/schema.go
+++ b/weed/mq/schema/schema.go
@@ -24,3 +24,30 @@ func (s *Schema) GetField(name string) (*schema_pb.Field, bool) {
field, ok := s.fieldMap[name]
return field, ok
}
+
+func TypeToString(t *schema_pb.Type) string {
+ switch t.Kind.(type) {
+ case *schema_pb.Type_ScalarType:
+ switch t.GetScalarType() {
+ case schema_pb.ScalarType_BOOL:
+ return "bool"
+ case schema_pb.ScalarType_INT32:
+ return "int32"
+ case schema_pb.ScalarType_INT64:
+ return "int64"
+ case schema_pb.ScalarType_FLOAT:
+ return "float"
+ case schema_pb.ScalarType_DOUBLE:
+ return "double"
+ case schema_pb.ScalarType_BYTES:
+ return "bytes"
+ case schema_pb.ScalarType_STRING:
+ return "string"
+ }
+ case *schema_pb.Type_ListType:
+ return "list"
+ case *schema_pb.Type_RecordType:
+ return "record"
+ }
+ return "unknown"
+}