Skip to content

Commit

Permalink
chore: bring back View for now
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Dec 21, 2023
1 parent ec3e37c commit 1216e47
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
@@ -1113,12 +1113,12 @@ def visit_FillNa(self, op, *, parent, replacements):
]
return sg.select(*exprs).from_(parent)

# @visit_node.register(ops.View)
# def visit_View(self, op, *, child, name: str):
# # TODO: find a way to do this without creating a temporary view
# backend = op.child.to_expr()._find_backend()
# backend._create_temp_view(table_name=name, source=sg.select(STAR).from_(child))
# return sg.table(name, quoted=self.quoted)
@visit_node.register(ops.View)
def visit_View(self, op, *, child, name: str):
# TODO: find a way to do this without creating a temporary view
backend = op.child.to_expr()._find_backend()
backend._create_temp_view(table_name=name, source=sg.select(STAR).from_(child))
return sg.table(name, quoted=self.quoted)

@visit_node.register(ops.SQLStringView)
def visit_SQLStringView(self, op, *, query: str, name: str, child):
12 changes: 12 additions & 0 deletions ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
@@ -416,6 +416,18 @@ def schema(self):
return backend._get_schema_using_query(self.query)


@public
class View(PhysicalTable):
"""A view created from an expression."""

child: Relation
name: str

@attribute
def schema(self):
return self.child.schema


@public
class DummyTable(Relation):
values: FrozenDict[str, Value]

0 comments on commit 1216e47

Please sign in to comment.