{"record":{"id":"785c08c6749c8f69","repo":"apache/beam","slug":"accessing-locals-with-is-not-yet-supported-https-github-com","errorCode":null,"errorMessage":"Accessing locals with @ is not yet supported (https://github.com/apache/beam/issues/20626)","messagePattern":"Accessing locals with @ is not yet supported \\(https://github\\.com/apache/beam/issues/20626\\)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":3352,"sourceCode":"      ))\n    else:\n      requires_partition_by = partitionings.Arbitrary()\n    return frame_base.DeferredFrame.wrap(\n        expressions.ComputedExpression(\n            'dropna',\n            lambda df: df.dropna(axis=axis, **kwargs),\n            [self._expr],\n            preserves_partition_by=partitionings.Arbitrary(),\n            requires_partition_by=requires_partition_by))\n\n  def _eval_or_query(self, name, expr, inplace, **kwargs):\n    for key in ('local_dict', 'global_dict', 'level', 'target', 'resolvers'):\n      if key in kwargs:\n        raise NotImplementedError(f\"Setting '{key}' is not yet supported\")\n\n    # look for '@<py identifier>'\n    if re.search(r'\\@[^\\d\\W]\\w*', expr, re.UNICODE):\n      raise NotImplementedError(\"Accessing locals with @ is not yet supported \"\n                                \"(https://github.com/apache/beam/issues/20626)\"\n                                )\n\n    result_expr = expressions.ComputedExpression(\n        name,\n        lambda df: getattr(df, name)(expr, **kwargs),\n        [self._expr],\n        requires_partition_by=partitionings.Arbitrary(),\n        preserves_partition_by=partitionings.Arbitrary())\n\n    if inplace:\n      self._expr = result_expr\n    else:\n      return frame_base.DeferredFrame.wrap(result_expr)\n\n\n  @frame_base.with_docs_from(pd.DataFrame)\n  @frame_base.args_to_kwargs(pd.DataFrame)","sourceCodeStart":3334,"sourceCodeEnd":3370,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L3334-L3370","documentation":"The Beam DataFrame API's query/eval support (_eval_or_query) rejects pandas' local-variable interpolation: when kwargs contain local_dict, global_dict, level, target, or resolvers (the '@' reference mechanism), this NotImplementedError fires because locals access is not yet supported (Beam issue 20626). Use literal expressions or precompute values instead.","triggerScenarios":"Calling df.query('a > @limit') or df.eval('b + @offset') on a Beam deferred DataFrame where the expression contains '@<identifier>'","commonSituations":"Porting pandas code that interpolates local variables into query/eval strings; migrating pipelines from pandas to Beam DataFrames","solutions":["Format the variable value directly into the expression string with an f-string","Use string concatenation for the constant value","Materialize with to_pandas() and run the @-based query in pandas"],"exampleFix":"// before\nresult = df.beam.query('a > @limit')\n// after\nresult = df.beam.query(f'a > {limit!r}')","handlingStrategy":"validation","validationCode":"import re\nif re.search(r'\\@[^\\d\\W]\\w*', expr):\n    raise ValueError('@-references are unsupported in Beam query/eval; inline the value')","typeGuard":null,"tryCatchPattern":"try:\n    out = dframe.query(f'a > {limit!r}')\nexcept NotImplementedError:\n    out = dframe.to_pandas().query('a > @limit')","preventionTips":["Search expression strings for '@' before calling query/eval on Beam frames","Use f-strings to embed constants","Add a unit test that runs all query expressions against a Beam frame"],"tags":["python","apache-beam","dataframe","query","locals-interpolation"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}