distributed-system-analysis / pbench

A benchmarking and performance analysis framework
http://distributed-system-analysis.github.io/pbench/
GNU General Public License v3.0
188 stars 108 forks source link

Implement filter by `dataset.owner` metadata #3558

Closed dbutenhof closed 1 year ago

dbutenhof commented 1 year ago

PBENCH-1278

dataset.owner is a "synthetic" metadata key, which actually represents the username column of the User row linked by the dataset's owner_id foreign key. The metadata system generates this when constructing the Dataset JSON object as it's useful data, and that's been sufficient to allow selection of ?metadata=dataset.owner.

However, dataset.owner is not a native Dataset column and therefore the key doesn't appear in the ?keysummary output (and isn't selectable for display in the UI), and can't be used either in ?filter or ?sort, which is unfortunate.

This PR adds a join and some minor special casing logic to ensure that the key is reported by ?keysummary, and to allow ?filter=dataset.owner:drb (or likely less useful constructs like ?filter=datset.owner:~dr or even ?filter=dataset.owner:>drb) as well as ?sort=dataset.owner.

While sqlite3 doesn't care, PostgreSQL insists that the sort field be in the SELECT set. Therefore, the datasets list query now returns both Dataset and User objects as a tuple, which the calling code needs to unpack. The changes are luckily minor.