From 3645cf4119620e8b01e57c7f9b5965400476f7d1 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Sun, 30 Jul 2023 09:11:19 -0400 Subject: [PATCH] fix(sql): handle parsing aliases --- ibis/expr/sql.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ibis/expr/sql.py b/ibis/expr/sql.py index f84c0bfde893..d1f0075803fc 100644 --- a/ibis/expr/sql.py +++ b/ibis/expr/sql.py @@ -60,6 +60,13 @@ def to_sqlglot(self): def overlay(self, step): updates = {dep.name: convert(dep, catalog=self) for dep in step.dependencies} + + # handle scan aliases: FROM foo AS bar + source = getattr(step, "source", None) + alias = getattr(source, "args", {}).get("alias") + if alias is not None and (source_name := self.get(source.name)) is not None: + self[alias.name] = source_name + return Catalog({**self, **updates})