in parquet/schema/reflection.go [214:315]
func infoFromTags(f reflect.StructTag) *taggedInfo {
typeFromStr := func(v string) parquet.Type {
t, err := format.TypeFromString(strings.ToUpper(v))
if err != nil {
panic(fmt.Errorf("invalid type specified: %s", v))
}
return parquet.Type(t)
}
repFromStr := func(v string) parquet.Repetition {
r, err := format.FieldRepetitionTypeFromString(strings.ToUpper(v))
if err != nil {
panic(err)
}
return parquet.Repetition(r)
}
convertedFromStr := func(v string) ConvertedType {
c, err := format.ConvertedTypeFromString(strings.ToUpper(v))
if err != nil {
panic(err)
}
return ConvertedType(c)
}
if ptags, ok := f.Lookup("parquet"); ok {
info := newTaggedInfo()
if ptags == "-" {
info.Exclude = true
return &info
}
for _, tag := range strings.Split(strings.Replace(ptags, "\t", "", -1), ",") {
tag = strings.TrimSpace(tag)
kv := strings.SplitN(tag, "=", 2)
key := strings.TrimSpace(strings.ToLower(kv[0]))
value := strings.TrimSpace(kv[1])
switch key {
case "name":
info.Name = value
case "type":
info.Type = typeFromStr(value)
case "keytype":
info.KeyType = typeFromStr(value)
case "valuetype":
info.ValueType = typeFromStr(value)
case "length":
info.Length = int32FromType(value)
case "keylength":
info.KeyLength = int32FromType(value)
case "valuelength":
info.ValueLength = int32FromType(value)
case "scale":
info.Scale = int32FromType(value)
case "keyscale":
info.KeyScale = int32FromType(value)
case "valuescale":
info.ValueScale = int32FromType(value)
case "precision":
info.Precision = int32FromType(value)
case "keyprecision":
info.KeyPrecision = int32FromType(value)
case "valueprecision":
info.ValuePrecision = int32FromType(value)
case "fieldid":
info.FieldID = int32FromType(value)
case "keyfieldid":
info.KeyFieldID = int32FromType(value)
case "valuefieldid":
info.ValueFieldID = int32FromType(value)
case "repetition":
info.RepetitionType = repFromStr(value)
case "valuerepetition":
info.ValueRepetition = repFromStr(value)
case "converted":
info.Converted = convertedFromStr(value)
case "keyconverted":
info.KeyConverted = convertedFromStr(value)
case "valueconverted":
info.ValueConverted = convertedFromStr(value)
case "logical":
info.LogicalFields["type"] = value
case "keylogical":
info.KeyLogicalFields["type"] = value
case "valuelogical":
info.ValueLogicalFields["type"] = value
default:
switch {
case strings.HasPrefix(key, "logical."):
info.LogicalFields[strings.TrimPrefix(key, "logical.")] = value
case strings.HasPrefix(key, "keylogical."):
info.KeyLogicalFields[strings.TrimPrefix(key, "keylogical.")] = value
case strings.HasPrefix(key, "valuelogical."):
info.ValueLogicalFields[strings.TrimPrefix(key, "valuelogical.")] = value
}
}
}
info.UpdateLogicalTypes()
return &info
}
return nil
}