Skip to content

Commit 751273b

Browse files
committed
refactor: rename View child to parent
1 parent 0938c47 commit 751273b

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

ibis/backends/polars/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ def execute_sql_string_view(op, *, ctx: pl.SQLContext, **kw):
13951395

13961396
@translate.register(ops.View)
13971397
def execute_view(op, *, ctx: pl.SQLContext, **kw):
1398-
child = translate(op.child, ctx=ctx, **kw)
1398+
child = translate(op.parent, ctx=ctx, **kw)
13991399
ctx.register(op.name, child)
14001400
return child
14011401

ibis/backends/sql/compilers/base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,19 +1545,19 @@ def visit_Limit(self, op, *, parent, n, offset):
15451545
def visit_CTE(self, op, *, parent):
15461546
return sg.table(parent.alias_or_name, quoted=self.quoted)
15471547

1548-
def visit_View(self, op, *, child, name: str):
1549-
if isinstance(child, sge.Table):
1550-
child = sg.select(STAR, copy=False).from_(child, copy=False)
1548+
def visit_View(self, op, *, parent, name: str):
1549+
if isinstance(parent, sge.Table):
1550+
parent = sg.select(STAR, copy=False).from_(parent, copy=False)
15511551
else:
1552-
child = child.copy()
1552+
parent = parent.copy()
15531553

1554-
if isinstance(child, sge.Subquery):
1555-
return child.as_(name, quoted=self.quoted)
1554+
if isinstance(parent, sge.Subquery):
1555+
return parent.as_(name, quoted=self.quoted)
15561556
else:
15571557
try:
1558-
return child.subquery(name, copy=False)
1558+
return parent.subquery(name, copy=False)
15591559
except AttributeError:
1560-
return child.as_(name, quoted=self.quoted)
1560+
return parent.as_(name, quoted=self.quoted)
15611561

15621562
def visit_SQLStringView(self, op, *, query: str, child, schema):
15631563
return sg.parse_one(query, read=self.dialect)

ibis/expr/operations/relations.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,11 @@ class SQLQueryResult(Relation):
438438
class View(PhysicalTable):
439439
"""A view created from an expression."""
440440

441-
# TODO(kszucs): rename it to parent
442-
child: Relation
441+
parent: Relation
443442

444443
@attribute
445444
def schema(self):
446-
return self.child.schema
445+
return self.parent.schema
447446

448447

449448
@public

ibis/expr/types/relations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,7 +3930,7 @@ def alias(self, alias: str, /) -> ir.Table:
39303930
│ Adelie │ Torgersen │ 36.7 │ 19.3 │ 193 │ … │
39313931
└─────────┴───────────┴────────────────┴───────────────┴───────────────────┴───┘
39323932
"""
3933-
return ops.View(child=self, name=alias).to_expr()
3933+
return ops.View(parent=self, name=alias).to_expr()
39343934

39353935
def sql(self, query: str, /, *, dialect: str | None = None) -> ir.Table:
39363936
'''Run a SQL query against a table expression.
@@ -4026,7 +4026,7 @@ def sql(self, query: str, /, *, dialect: str | None = None) -> ir.Table:
40264026

40274027
if isinstance(op, ops.View):
40284028
name = op.name
4029-
expr = op.child.to_expr()
4029+
expr = op.parent.to_expr()
40304030
else:
40314031
name = util.gen_name("sql_query")
40324032
expr = self

0 commit comments

Comments
 (0)