Skip to content

Commit 19ca6d3

Browse files
committed
chore: Fix _expr_output_name coverage
#3233 (comment)
1 parent e8eb22e commit 19ca6d3

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

narwhals/_plan/meta.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,15 @@ def _expr_output_name(expr: ir.ExprIR, /) -> str | ComputeError:
107107
if isinstance(e, (ir.Column, ir.Alias, ir.Literal, ir.Len)):
108108
return e.name
109109
if isinstance(e, ir.RenameAlias):
110-
parent_name = _expr_output_name(e.expr)
111-
if isinstance(parent_name, str):
112-
return e.function(parent_name)
113-
return parent_name
110+
parent = _expr_output_name(e.expr)
111+
return e.function(parent) if isinstance(parent, str) else parent
114112
if isinstance(e, ir.KeepName):
115113
msg = "cannot determine output column without a context for this expression"
116114
return ComputeError(msg)
117-
# https://github.com/pola-rs/polars/pull/24064
118-
if isinstance(e, ir.SelectorIR):
119-
# Selector with single `by_name` is fine.
120-
if (
121-
isinstance(e, ir.RootSelector)
122-
and isinstance(e.selector, cs.ByName)
123-
and len(e.selector.names) == 1
124-
):
125-
return e.selector.names[0]
126-
# Other selectors aren't possible right now.
127-
break
128-
continue
115+
if isinstance(e, ir.RootSelector) and (
116+
isinstance(e.selector, cs.ByName) and len(e.selector.names) == 1
117+
):
118+
return e.selector.names[0]
129119
msg = (
130120
f"unable to find root column name for expr '{expr!r}' when calling 'output_name'"
131121
)

0 commit comments

Comments
 (0)