apache/beam · error · ValueError

TableFunctionQueryConfig must provide where_clause_value_fn

Error message

TableFunctionQueryConfig must provide where_clause_value_fn

What it means

TableFunctionQueryConfig.__post_init__ validates its three required fields; where_clause_value_fn is falsy (None or an empty callable reference), so the config has no way to extract WHERE-clause values from input rows.

Solutions

  1. Pass a callable where_clause_value_fn that computes condition values from the input row
  2. Verify the callable is defined/imported before constructing the config
  3. Switch to TableFieldsQueryConfig (field-based values) if a custom function is not needed

Example fix

// before
TableFunctionQueryConfig(table_id='users', where_clause_template='WHERE id = :id', where_clause_value_fn=None)
// after
TableFunctionQueryConfig(table_id='users', where_clause_template='WHERE id = :id', where_clause_value_fn=lambda row: {'id': row['user_id']})
Defensive patterns

Strategy: validation

Validate before calling

def make_table_fn_config(table_id, tmpl, fn):
    if not callable(fn):
        raise ValueError('where_clause_value_fn must be a callable')
    return TableFunctionQueryConfig(table_id, tmpl, fn)

Type guard

def is_condition_value_fn(v) -> bool:
    return callable(v)

Try / catch

try:
    cfg = TableFunctionQueryConfig(**raw)
except ValueError as e:
    raise ValueError('where_clause_value_fn is mandatory for TableFunctionQueryConfig') from e

Prevention

When it happens

Trigger: TableFunctionQueryConfig(table_id='t', where_clause_template='WHERE x = :x', where_clause_value_fn=None) or omitting the field.

Common situations: Forgetting the callable when copying the constructor signature; the function reference is defined later/further away and None is passed by default.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/0bdb1820f07bf5a7. Report an issue: GitHub.

Appendix: source

Thrown at sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py:88

          "TableFieldsQueryConfig must provide non-empty " +
          "where_clause_fields")


@dataclass
class TableFunctionQueryConfig:
  """Configuration for using table name, where clause, and a value function."""
  table_id: str
  where_clause_template: str
  where_clause_value_fn: ConditionValueFn

  def __post_init__(self):
    if not self.table_id or not self.where_clause_template:
      raise ValueError(
          "TableFunctionQueryConfig must provide table_id and " +
          "where_clause_template")

    if not self.where_clause_value_fn:
      raise ValueError(
          "TableFunctionQueryConfig must provide " + "where_clause_value_fn")


class DatabaseTypeAdapter(Enum):
  POSTGRESQL = "pg8000"
  MYSQL = "pymysql"
  SQLSERVER = "pytds"

  def to_sqlalchemy_dialect(self):
    """Map the adapter type to its corresponding SQLAlchemy dialect.

    Returns:
        str: SQLAlchemy dialect string.
    """
    if self == DatabaseTypeAdapter.POSTGRESQL:
      return f"postgresql+{self.value}"
    elif self == DatabaseTypeAdapter.MYSQL:
      return f"mysql+{self.value}"

View on GitHub (pinned to 12126d8942)