zed icon indicating copy to clipboard operation
zed copied to clipboard

Referencing join predicate paths from inside a User Op

Open philrz opened this issue 8 months ago • 0 comments

With the current join implementation, there's currently no way to reference the second order predicate paths when inside a User Op.

Details

Repro is with super commit f86de86.

Let's start with this simple join that uses the input data from the Join Tutorial.

$ super -version
Version: f86de86d5

$ super -c "
from fruit.json
| inner join (
  from people.json
) on left.flavor=right.likes
| values {...left, eater:right.name}"

{name:"figs",color:"brown",flavor:"plain",eater:"jessie"}
{name:"banana",color:"yellow",flavor:"sweet",eater:"quinn"}
{name:"strawberry",color:"red",flavor:"sweet",eater:"quinn"}
{name:"dates",color:"brown",flavor:"sweet",note:"in season",eater:"quinn"}
{name:"apple",color:"red",flavor:"tart",eater:"morgan"}
{name:"apple",color:"red",flavor:"tart",eater:"chris"}

I can easily wrap it in a User Op, call that User Op, and it produces the same result.

$ super -c "
op JoinInOp(): (
  from fruit.json
  | inner join (
    from people.json
  ) on left.flavor=right.likes
  | values {...left, eater:right.name}
) 

JoinInOp()"

{name:"figs",color:"brown",flavor:"plain",eater:"jessie"}
{name:"banana",color:"yellow",flavor:"sweet",eater:"quinn"}
{name:"strawberry",color:"red",flavor:"sweet",eater:"quinn"}
{name:"dates",color:"brown",flavor:"sweet",note:"in season",eater:"quinn"}
{name:"apple",color:"red",flavor:"tart",eater:"morgan"}
{name:"apple",color:"red",flavor:"tart",eater:"chris"}

However, if we focus on this particular line:

on left.flavor=right.likes

There's currently no way to, for example, pass the values flavor and/or likes into the User Op and have them referenced in the join predicate such as if I wanted to make the join flexible to different field names.

philrz avatar Jul 01 '25 22:07 philrz