perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

Ability to create derived values/columns in table/pivot views

Open anakryiko opened this issue 10 months ago • 3 comments

It would be extremely useful to be able to create a derived values/columns in table/pivot views that would take some other values (e.g., two other columns) and calculate some expression. That calculated value can then be used for sorting or charting.

Ideally, some simple subset of SQL would be allowed, which would cover both arithmetics, but also would allow to call into various math/string functions.

anakryiko avatar Jan 06 '26 00:01 anakryiko

@stevegolton would be the person for this

aMayzner avatar Jan 06 '26 09:01 aMayzner

Good idea: a few notes and clarifying questions:

  • PivotTable is deprecated and should not be used in any new code. This isn't obvious - I need to mark it as deprecated. Please use DataGrid for any tables / pivot tables. There's various of examples of how to use it around the codebase.
  • If you were to add this functionality, please add it to DataGrid instead. Happy to discuss. DataGrid is much more generic so it could be a little more tricky to implement.
  • I'm assuming this is for the end user to use (rather than a plugin developer). I'm assuming this because a developer could simply add a new column to their SQL statement so the pivot table need be none the wiser.
  • Why do we need to allow only a subset of SQL? I feel like it could be difficult to constrain this + why not just support any old SQL expression?

stevegolton avatar Jan 07 '26 10:01 stevegolton

I'm assuming this is for the end user to use (rather than a plugin developer). I'm assuming this because a developer could simply add a new column to their SQL statement so the pivot table need be none the wiser.

yes, for normal user opening some trace and trying to analyze data using standard table views

Why do we need to allow only a subset of SQL? I feel like it could be difficult to constrain this + why not just support any old SQL expression?

When I said subset of SQL, it was more in the spirit of "at least some useful subset of SQL" so that some arithmetic expressions could be expressed. I didn't mean to limit it to a subset of SQL, though. If full SQL is possible, yeah, why not?

anakryiko avatar Jan 07 '26 20:01 anakryiko