Skip to content

[DF] Let Aliases be defined per computation graph branch, not globally #7381

@eguiraud

Description

@eguiraud

Is your feature request related to a problem? Please describe.

While users can Define a column with the same name in different branches of the computation graph, that's not true for Aliases: they are global to the computation graph. For example, this fails:

#include <ROOT/RDataFrame.hxx>
#include <iostream>

int main() {
   auto df = ROOT::RDataFrame(1).Define("x", [] { return 42; }).Define("y", [] { return 0; });
   auto dfzx = df.Alias("z", "x");
   auto dfzy = df.Alias("z", "y");
   auto max42 = dfzx.Max<int>("z");
   auto max0 = dfzy.Max<int>("z");
   std::cout << "should be 42: " << *max42 << '\n';
   std::cout << "should be 0: " << *max0 << '\n';

   return 0;
}

Describe the solution you'd like

Aliases should behave the same as Defines, we should track them per-computation-graph-branch rather than per-computation-graph.

Additional context

That would make it possible to Redefine aliases, which is currently not a thing because we don't want a computation-graph-branch-local Redefine to undefine a global Alias.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions