{"record":{"id":"7104bf1a6a1db1f6","repo":"pola-rs/polars","slug":"cannot-turn-qualified-type-name-input-r-into-se","errorCode":null,"errorMessage":"cannot turn {qualified_type_name(input)!r} into selector","messagePattern":"cannot turn (.+?) into selector","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/parse/expr.py","lineNumber":65,"sourceCode":"        If the input is expected to resolve to a literal with a known dtype, pass\n        this to the `lit` constructor.\n    require_selector\n        Require that the input is a valid selector (eg: column name or selector).\n\n    Returns\n    -------\n    PyExpr\n    \"\"\"\n    if isinstance(input, pl.Expr):\n        expr = input\n        if structify:\n            expr = _structify_expression(expr)\n    elif isinstance(input, str) and not str_as_lit:\n        expr = F.col(input)\n    else:\n        if require_selector:\n            msg = f\"cannot turn {qualified_type_name(input)!r} into selector\"\n            raise TypeError(msg)\n        elif isinstance(input, list) and list_as_series:\n            expr = F.lit(pl.Series(input), dtype=dtype)\n        else:\n            expr = F.lit(input, dtype=dtype)\n\n    return expr._pyexpr\n\n\ndef _structify_expression(expr: Expr) -> Expr:\n    unaliased_expr = expr.meta.undo_aliases()\n    if unaliased_expr.meta.has_multiple_outputs():\n        try:\n            expr_name = expr.meta.output_name()\n        except ComputeError:\n            expr = F.struct(expr)\n        else:\n            expr = F.struct(unaliased_expr).alias(expr_name)\n    return expr","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/_utils/parse/expr.py#L47-L83","documentation":"parse_into_expression with require_selector=True backs parse_into_list_of_expressions_require_selectors, whose only caller is LazyFrame.unique(subset=...) (lazyframe/frame.py:8275; DataFrame.unique delegates through lazy). Each subset element must be a column name (str) or a selector expression (pl.Expr / pl.Selector); anything else cannot name columns and raises this TypeError instead of being treated as a literal value.","triggerScenarios":"df.unique(subset=0) (integer position); df.unique(subset=[0, 1]); df.unique(subset=pl.Series(['a'])); df.unique(subset=some_dict); floats or None inside the subset list.","commonSituations":"Passing pandas-style integer column positions; passing a Series of names produced upstream; refactoring from select()/drop() call sites where other input types are accepted.","solutions":["Pass column names: df.unique(subset=['a', 'b'])","Pass selector expressions: df.unique(subset=cs.numeric()) or df.unique(subset=pl.col('label').str.extract(r'^(\\w+):'))","Convert Series to a list: df.unique(subset=names.to_list())"],"exampleFix":"# before\ndf.unique(subset=pl.Series([\"a\", \"b\"]))\n\n# after\ndf.unique(subset=[\"a\", \"b\"])  # or names.to_list()","handlingStrategy":"type-guard","validationCode":"import polars as pl\n\nif isinstance(subset, pl.Series):\n    subset = subset.to_list()\nif not all(isinstance(s, (str, pl.Expr)) for s in subset):\n    raise TypeError(\"unique subset accepts only column names or expressions\")\ndf.unique(subset=subset)","typeGuard":"import polars as pl\n\ndef is_valid_subset(subset) -> bool:\n    if isinstance(subset, (str, pl.Expr)):\n        return True\n    return isinstance(subset, (list, tuple)) and all(\n        isinstance(s, (str, pl.Expr)) for s in subset\n    )","tryCatchPattern":null,"preventionTips":["Pass column names or cs-Selectors to unique(subset=...), never positions or Series","Convert Series with .to_list() at the boundary","Type-annotate subset parameters as Sequence[str | pl.Expr] to catch regressions"],"tags":["python","polars","unique","selector","expression","typeerror"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}