def get_scope_stmt(path_id: irast.PathId, *, ctx: context.CompilerContextLevel) -> pgast.Query: stmt = ctx.path_scope.get(path_id) if stmt is None and path_id.is_ptr_path(): stmt = ctx.path_scope.get(path_id.tgt_path()) if stmt is None: raise LookupError(f'cannot find scope statement for {path_id}') return stmt
def maybe_get_scope_stmt( path_id: irast.PathId, *, ctx: context.CompilerContextLevel, ) -> Optional[pgast.SelectStmt]: stmt = ctx.path_scope.get(path_id) if stmt is None and path_id.is_ptr_path(): stmt = ctx.path_scope.get(path_id.tgt_path()) return stmt