Skip to content

Commit

Permalink
refactor(ir): wrap JoinChain.first in ops.SelfReference similar t…
Browse files Browse the repository at this point in the history
…o the rest of the join tables
  • Loading branch information
kszucs committed Feb 12, 2024
1 parent 2a2f8c6 commit 15bd926
Show file tree
Hide file tree
Showing 13 changed files with 730 additions and 662 deletions.
2 changes: 1 addition & 1 deletion ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class JoinLink(Node):

@public
class JoinChain(Relation):
first: Relation
first: SelfReference
rest: VarTuple[JoinLink]
values: FrozenDict[str, Unaliased[Value]]

Expand Down
26 changes: 14 additions & 12 deletions ibis/expr/tests/snapshots/test_format/test_asof_join/repr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ r1 := UnboundTable: right
time2 int32
value2 float64

r2 := SelfReference[r1]
r2 := SelfReference[r0]

r3 := SelfReference[r1]

JoinChain[r0]
JoinLink[asof, r2]
r0.time1 == r2.time2
JoinLink[inner, r3]
r0.value == r3.value2
r4 := SelfReference[r1]

JoinChain[r2]
JoinLink[asof, r3]
r2.time1 == r3.time2
JoinLink[inner, r4]
r2.value == r4.value2
values:
time1: r0.time1
value: r0.value
time2: r2.time2
value2: r2.value2
time2_right: r3.time2
value2_right: r3.value2
time1: r2.time1
value: r2.value
time2: r3.time2
value2: r3.value2
time2_right: r4.time2
value2_right: r4.value2
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ r4 := SelfReference[r2]
r5 := Filter[r0]
r0.f > 0

JoinChain[r5]
r6 := SelfReference[r5]

JoinChain[r6]
JoinLink[left, r3]
r5.foo_id == r3.foo_id
r6.foo_id == r3.foo_id
JoinLink[inner, r4]
r5.bar_id == r4.bar_id
r6.bar_id == r4.bar_id
values:
c: r5.c
f: r5.f
foo_id: r5.foo_id
bar_id: r5.bar_id
c: r6.c
f: r6.f
foo_id: r6.foo_id
bar_id: r6.bar_id
value1: r3.value1
value2: r4.value2
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ r2 := Filter[r1]
r3 := Filter[r1]
r1.kind == 'bar'

r4 := SelfReference[r3]
r4 := SelfReference[r2]

JoinChain[r2]
JoinLink[inner, r4]
r2.region == r4.region
r5 := SelfReference[r3]

JoinChain[r4]
JoinLink[inner, r5]
r4.region == r5.region
values:
region: r2.region
kind: r2.kind
total: r2.total
right_total: r4.total
region: r4.region
kind: r4.kind
total: r4.total
right_total: r5.total
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ r1 := UnboundTable: t2
a int64
b float64

r2 := SelfReference[r1]
r2 := SelfReference[r0]

r3 := JoinChain[r0]
JoinLink[inner, r2]
r0.a == r2.a
r3 := SelfReference[r1]

r4 := JoinChain[r2]
JoinLink[inner, r3]
r2.a == r3.a
values:
a: r0.a
b: r0.b
a_right: r2.a
b_right: r2.b
a: r2.a
b: r2.b
a_right: r3.a
b_right: r3.b

CountStar(): CountStar(r3)
CountStar(): CountStar(r4)
30 changes: 16 additions & 14 deletions ibis/expr/tests/snapshots/test_format/test_two_inner_joins/repr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ r1 := UnboundTable: right
value2 float64
b string

r2 := SelfReference[r1]
r2 := SelfReference[r0]

r3 := SelfReference[r1]

JoinChain[r0]
JoinLink[inner, r2]
r0.a == r2.b
r4 := SelfReference[r1]

JoinChain[r2]
JoinLink[inner, r3]
r0.value == r3.value2
r2.a == r3.b
JoinLink[inner, r4]
r2.value == r4.value2
values:
time1: r0.time1
value: r0.value
a: r0.a
time2: r2.time2
value2: r2.value2
b: r2.b
time2_right: r3.time2
value2_right: r3.value2
b_right: r3.b
time1: r2.time1
value: r2.value
a: r2.a
time2: r3.time2
value2: r3.value2
b: r3.b
time2_right: r4.time2
value2_right: r4.value2
b_right: r4.b
Loading

0 comments on commit 15bd926

Please sign in to comment.