in out_writeapi.go [87:118]
func mangleInputSchema(input *storagepb.TableSchema, dataTimeString bool) *storagepb.TableSchema {
if input == nil {
return nil
}
// Create a clone of the table schema
newMsg := proto.Clone(input).(*storagepb.TableSchema)
newMsg.Fields = make([]*storagepb.TableFieldSchema, len(input.GetFields()))
for k, f := range input.GetFields() {
// Create a clone of the field
newF := proto.Clone(f).(*storagepb.TableFieldSchema)
switch newF.GetType() {
// Overwrite the field to be string
case storagepb.TableFieldSchema_NUMERIC,
storagepb.TableFieldSchema_BIGNUMERIC,
storagepb.TableFieldSchema_TIME,
storagepb.TableFieldSchema_JSON:
newF.Type = storagepb.TableFieldSchema_STRING
}
// If datatimestring is true, then set the field type to string
if newF.GetType() == storagepb.TableFieldSchema_DATETIME && dataTimeString {
newF.Type = storagepb.TableFieldSchema_STRING
}
// If the field is a struct type it will have a non-zero number of fields
if len(newF.GetFields()) > 0 {
// Call mangeInputSchema on the fields in the struct
newF.Fields = mangleInputSchema(&storagepb.TableSchema{Fields: newF.Fields}, dataTimeString).Fields
}
newMsg.Fields[k] = newF
}
return newMsg
}