{"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":64,"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":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/parse/expr.py#L46-L82","documentation":"parse_into_expression converts Python inputs into polars expressions. When require_selector is set, the input must be a string, Selector, or Expr; anything else (int, dict, arbitrary object) cannot become a selector, so a TypeError is raised with the qualified type name.","triggerScenarios":"Calling APIs like pl.selectors-consuming methods or functions that route through parse_into_expression(require_selector=True) with a non-selector value, e.g. df.select(42), pl.slice with a non-string, or passing a list of wrong types where selectors are expected.","commonSituations":"Typos like passing column positions where names are expected, passing dicts/sets instead of column name strings, or mixing literals into selector-only contexts.","solutions":["Pass a column name string (converted to F.col) or a pl.selectors.* selector.","Wrap a literal explicitly with pl.lit(value) if you intended a literal, or pl.col(name) for a column.","Use pl.Expr.meta.as_selector()-compatible expressions only where selectors are allowed.","Check the function signature to see whether it expects expressions, selectors, or names."],"exampleFix":"// before\ndf.select(42)\n// after\ndf.select(pl.col(\"column_name\"))  # or df.select(pl.selectors.by_index(42))","handlingStrategy":"type-guard","validationCode":"def ensure_selector_input(x):\n    import polars as pl\n    if isinstance(x, (str, pl.Selector, pl.Expr)):\n        return x\n    raise TypeError(f\"cannot use {type(x).__name__} as selector; use str/Selector/Expr\")","typeGuard":"def is_selector_input(x) -> bool:\n    import polars as pl\n    return isinstance(x, (str, pl.Selector, pl.Expr))","tryCatchPattern":"try:\n    result = df.select(inputs)\nexcept TypeError as e:\n    if \"into selector\" in str(e):\n        result = df.select([pl.lit(v).alias(k) for k, v in inputs.items()])\n    else:\n        raise","preventionTips":["Pass strings or pl.selectors.* objects where selectors are expected.","Wrap literals with pl.lit and columns with pl.col explicitly.","Read the signature: require_selector APIs reject raw values.","Add input validation at API boundaries that forward user data to select-like calls."],"tags":["polars","selectors","type-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}