Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove unneeded alias
Browse files Browse the repository at this point in the history
MarcoGorelli committed Jan 8, 2025
1 parent 66b17e9 commit 7554559
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions narwhals/_duckdb/expr.py
Original file line number Diff line number Diff line change
@@ -414,17 +414,15 @@ def n_unique(self) -> Self:
from duckdb import FunctionExpression

def func(_input: duckdb.Expression) -> duckdb.Expression:
return (
FunctionExpression(
"array_unique", FunctionExpression("array_agg", _input)
)
+ FunctionExpression(
"max",
CaseExpression(
condition=_input.isnotnull(), value=ConstantExpression(0)
).otherwise(ConstantExpression(1)),
)
).alias("result")
# https://stackoverflow.com/a/79338887/4451315
return FunctionExpression(
"array_unique", FunctionExpression("array_agg", _input)
) + FunctionExpression(
"max",
CaseExpression(
condition=_input.isnotnull(), value=ConstantExpression(0)
).otherwise(ConstantExpression(1)),
)

return self._from_call(
func,

0 comments on commit 7554559

Please sign in to comment.