Closed dkumor closed 1 month ago
When compute schema
of the expression in agg
, we did not perform any special processing for Function
and AnonymousFunction
. Actually, we only take column
as a special case in AggContext
. That is to say:
the schema of
pl.DataFrame([{
"a":1,
"b":2
}]).lazy().group_by('a').agg(
pl.struct([col('b')]).alias('s')
)
is {'a ': Int64,'s': Struct ([Field ('b', Int64)]}
, which should actually be {'a ': Int64,'s': List(Struct ([Field ('b', Int64)]})
.
@ritchie46 What do you think about this? How about nesting the field's dtype
of each expr
in agg
into a List
, except for those that auto-explode like sum... 🤔
This has been fixed. Closing.
Checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of Polars.
Reproducible example
Output:
Log output
Issue description
Doing an aggregation that creates a list of structs, then getting a field from the first list element fails in LazyFrame. Running collect before getting the struct field succeeds.
Expected behavior
Output:
Installed versions