diff --git a/ibis/expr/types/generic.py b/ibis/expr/types/generic.py index fb0ff37bb2b4..87a0b7e69bb1 100644 --- a/ibis/expr/types/generic.py +++ b/ibis/expr/types/generic.py @@ -1247,9 +1247,15 @@ def as_table(self) -> ir.Table: op = self.op() table = find_first_base_table(op) if table is not None: - return table.to_expr().aggregate([self]) + return table.to_expr().aggregate(**{self.get_name(): self}) else: - return ops.DummyTable(values=(op,)).to_expr() + if isinstance(op, ops.Alias): + value = op + assert value.name == self.get_name() + else: + value = ops.Alias(op, self.get_name()) + + return ops.DummyTable(values=(value,)).to_expr() def __deferred_repr__(self): return f""