in wstl1/tools/notebook/extensions/wstl/service/wstlserver/context.go [159:198]
func executeTransformation(trans transform.Transformer, inputs []*wspb.Location) []*wspb.TransformedRecords {
results := []*wspb.TransformedRecords{}
for _, input := range inputs {
tRecord := &wspb.TransformedRecords{}
var source json.RawMessage
switch l := input.GetLocation().(type) {
case *wspb.Location_InlineJson:
source = json.RawMessage(l.InlineJson)
case *wspb.Location_GcsLocation:
var err error
if source, err = gcsutil.ReadFromGcs(context.Background(), l.GcsLocation); err != nil {
tRecord.Record = &wspb.TransformedRecords_Error{
Error: status.New(codes.InvalidArgument, err.Error()).Proto(),
}
results = append(results, tRecord)
continue
}
default:
tRecord.Record = &wspb.TransformedRecords_Error{
Error: status.New(codes.InvalidArgument, "unsupported input type").Proto(),
}
results = append(results, tRecord)
continue
}
output, err := trans.JSONtoJSON(source)
if err != nil {
tRecord.Record = &wspb.TransformedRecords_Error{
Error: status.New(codes.InvalidArgument, err.Error()).Proto(),
}
} else {
tRecord.Record = &wspb.TransformedRecords_Output{
Output: string(output),
}
}
results = append(results, tRecord)
}
return results
}