Skip to content

Get the column name that this expression would produce

Description

It may not always be possible to determine the output name as that can depend on the schema of the context; in that case this will raise an error if raise_if_undetermined = TRUE (the default), and return NA otherwise.

Usage

<Expr>$meta$output_name(..., raise_if_undetermined = TRUE)

Arguments

These dots are for future extensions and must be empty.
raise_if_undetermined If TRUE (default), raise an error if the output name cannot be determined. Otherwise return NA.

Value

A polars expression

Examples

library("polars")

e <- pl$col("foo") * pl$col("bar")
e$meta$output_name()
#> [1] "foo"
e_filter <- pl$col("foo")$filter(pl$col("bar") == 13)
e_filter$meta$output_name()
#> [1] "foo"
e_sum_over <- pl$col("foo")$sum()$over("groups")
e_sum_over$meta$output_name()
#> [1] "foo"
e_sum_slice <- pl$col("foo")$sum()$slice(pl$len() - 10, pl$col("bar"))
e_sum_slice$meta$output_name()
#> [1] "foo"
pl$len()$meta$output_name()
#> [1] "len"