Skip to content

Commit

Permalink
revert: chore(ir): tie the uniqueness of a self reference to its parent
Browse files Browse the repository at this point in the history
This reverts commit 03d08d2.
  • Loading branch information
cpcloud committed Dec 12, 2023
1 parent 03d08d2 commit 5b1a78b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ def visit_DatabaseTable(self, op, *, name, namespace, schema, source):
)

@visit_node.register(ops.SelfReference)
def visit_SelfReference(self, op, *, parent):
def visit_SelfReference(self, op, *, parent, identifier):
return parent.as_(op.name, quoted=self.quoted)

@visit_node.register(ops.JoinChain)
Expand Down
11 changes: 8 additions & 3 deletions ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import itertools
import typing
from abc import abstractmethod
from typing import TYPE_CHECKING, Annotated, Any, Literal, Optional
Expand Down Expand Up @@ -261,11 +262,15 @@ def schema(self):

@public
class SelfReference(Relation):
_uid_counter = itertools.count()

parent: Relation
identifier: Optional[int] = None

@attribute
def identifier(self):
return hash(self.parent)
def __init__(self, parent, identifier):
if identifier is None:
identifier = next(self._uid_counter)
super().__init__(parent=parent, identifier=identifier)

@attribute
def name(self) -> str:
Expand Down

0 comments on commit 5b1a78b

Please sign in to comment.