Skip to content

Commit

Permalink
fix(ir): self reference fields were incorrectly dereferenced to the p…
Browse files Browse the repository at this point in the history
…arent relation
  • Loading branch information
kszucs committed Feb 12, 2024
1 parent 9fb3627 commit 7bfebe2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
t7.r_name,
t2.r_name,
t7.n_name
FROM tpch_region AS t2
INNER JOIN tpch_nation AS t3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ WHERE
ON t7.o_custkey = t6.c_custkey
) AS t12
WHERE
t12.region = t12.region
t12.region = t11.region
) AS t13
)
LIMIT 10
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ WHERE
t1.y
FROM foo AS t1
WHERE
t1.dept_id = t1.dept_id
t0.dept_id = t1.dept_id
) AS t2
)
4 changes: 4 additions & 0 deletions ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ def __init__(self, parent, identifier):
identifier = next(self._uid_counter)
super().__init__(parent=parent, identifier=identifier)

@attribute
def values(self):
return FrozenDict()


JoinKind = Literal[
"inner",
Expand Down
25 changes: 25 additions & 0 deletions ibis/expr/tests/test_dereference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import annotations

import ibis
from ibis.expr.types.relations import dereference_mapping

t = ibis.table(
[
("int_col", "int32"),
("double_col", "double"),
("string_col", "string"),
],
name="t",
)


def dereference_expect(expected):
return {k.op(): v.op() for k, v in expected.items()}


def test_dereference_mapping_self_reference():
v = t.view()

mapping = dereference_mapping([v.op()])
expected = dereference_expect({})
assert mapping == expected

0 comments on commit 7bfebe2

Please sign in to comment.