{"record":{"id":"61abaa4760db5e6b","repo":"apache/beam","slug":"columns-are-not-specified-please-specify-the-column-for-the","errorCode":null,"errorMessage":"Columns are not specified. Please specify the column for the  op %s","messagePattern":"Columns are not specified\\. Please specify the column for the  op (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/transforms/tft.py","lineNumber":97,"sourceCode":"\n\n# TODO: https://github.com/apache/beam/pull/29016\n# Add support for outputting artifacts to a text file in human readable form.\nclass TFTOperation(BaseOperation[common_types.TensorType,\n                                 common_types.TensorType]):\n  def __init__(self, columns: list[str]) -> None:\n    \"\"\"\n    Base Operation class for TFT data processing transformations.\n    Processing logic for the transformation is defined in the\n    apply_transform() method. If you have a custom transformation that is not\n    supported by the existing transforms, you can extend this class\n    and implement the apply_transform() method.\n    Args:\n      columns: List of column names to apply the transformation.\n    \"\"\"\n    super().__init__(columns)\n    if not columns:\n      raise RuntimeError(\n          \"Columns are not specified. Please specify the column for the \"\n          \" op %s\" % self.__class__.__name__)\n\n  def get_ptransform_for_processing(self, **kwargs) -> beam.PTransform:\n    from apache_beam.ml.transforms.handlers import TFTProcessHandler\n    params = {}\n    artifact_location = kwargs.get('artifact_location')\n    if not artifact_location:\n      raise RuntimeError(\n          \"artifact_location is not specified. Please specify the \"\n          \"artifact_location for the op %s\" % self.__class__.__name__)\n\n    artifact_mode = kwargs.get('artifact_mode')\n    if artifact_mode:\n      params['artifact_mode'] = artifact_mode\n    return TFTProcessHandler(artifact_location=artifact_location, **params)\n\n  @tf.function","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/transforms/tft.py#L79-L115","documentation":"All TFT transform op base classes (ApplyTransforms base in tft.py) require a non-empty columns list identifying which PCollection columns the transform applies to. The __init__ raises a RuntimeError when columns is falsy (None, empty list), because apply_transform would otherwise have no target column.","triggerScenarios":"Constructing a TFT transform config like ScaleToZScore(), ScaleMinMax(), ComputeAndApplyVocab() with columns=None or columns=[] (or omitting the first positional argument).","commonSituations":"Building transform configs programmatically from empty config lists, copy-pasting a transform instantiation without filling in column names, or a config loader returning an empty columns key.","solutions":["Pass the target column name(s): e.g. ScaleToZScore(columns=['feature_1']).","Verify the source of the columns list is non-empty before constructing configs.","Validate column names against the PCollection schema so downstream key errors are also avoided."],"exampleFix":"# before\ntransform = tft.ScaleToZScore()  # columns missing\n\n# after\ntransform = tft.ScaleToZScore(columns=['age'])","handlingStrategy":"validation","validationCode":"def make_scale_zscore(columns):\n    if not columns:\n        raise ValueError('columns must be a non-empty list of column names')\n    return tft.ScaleToZScore(columns=columns)","typeGuard":"def has_columns(columns) -> bool:\n    return isinstance(columns, (list, tuple)) and len(columns) > 0 and all(isinstance(c, str) for c in columns)","tryCatchPattern":"try:\n    transforms = [tft.ScaleToZScore(columns=cols)]\nexcept RuntimeError as e:\n    if 'Columns are not specified' in str(e):\n        raise ValueError(f'Provide target columns for transform: {e}') from e\n    raise","preventionTips":["Always pass columns as the first argument to every TFT transform config.","Validate the transform-config list (non-empty columns) before building MLTransform.","Use keyword arguments (columns=[...]) to avoid positional mix-ups.","Add a schema test asserting each config targets an existing column."],"tags":["python","apache-beam","tft","missing-argument"],"backgroundTag":"missing-required-argument","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"}