It looks as though this might be databricks secret sauce. You can achieve the same result by just using
transform(mapped_trace, x -> transform(x.segments, y -> y.shape))