apache/beam · error · RuntimeError

Create disposition has to be one of the following…

Error message

Create disposition has to be one of the following values:CREATE_IF_NEEDED, CREATE_NEVER. Got: {}

What it means

In Beam's Snowflake connector, CreateDisposition.VerifyParam checks that the given create-disposition string matches one of the class constants CREATE_IF_NEEDED or CREATE_NEVER. It raises RuntimeError when a truthy value does not correspond to any defined attribute, protecting against misspelled or unsupported disposition names.

Solutions

  1. Use the constant CreateDisposition.CREATE_IF_NEEDED or CreateDisposition.CREATE_NEVER instead of a raw string
  2. Fix casing — values must be uppercase exactly as defined
  3. Check for typos in the configured pipeline option
  4. Pass None/empty to leave the disposition unset (verification is skipped when falsy)

Example fix

// before
snowflake.WriteToSnowflake(create_disposition='create_if_needed')
// after
from apache_beam.io.snowflake import CreateDisposition
snowflake.WriteToSnowflake(create_disposition=CreateDisposition.CREATE_IF_NEEDED)
Defensive patterns

Strategy: validation

Validate before calling

from apache_beam.io.snowflake import CreateDisposition
assert create_disposition in (None, '', CreateDisposition.CREATE_IF_NEEDED, CreateDisposition.CREATE_NEVER)

Type guard

def is_valid_create_disposition(v):
    return not v or v in ('CREATE_IF_NEEDED', 'CREATE_NEVER')

Try / catch

try:
    transform = snowflake.WriteToSnowflake(create_disposition=cd)
except RuntimeError as e:
    logger.error('Invalid create disposition: %s', e)

Prevention

When it happens

Trigger: Passing a create_disposition value like 'create_if_needed' (wrong case), 'CREATE_IF_NESSED' (typo), or any string that is not exactly CREATE_IF_NEEDED / CREATE_NEVER to a Snowflake write transform.

Common situations: Copying Java Beam enum names with different casing, typos in pipeline options, or using a value valid in another connector but not Snowflake.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/io/snowflake.py:458

            self.expansion_service))


class CreateDisposition:
  """
  Enum class for possible values of create dispositions:
  CREATE_IF_NEEDED: default behaviour. The write operation checks whether
  the specified target table exists; if it does not, the write operation
  attempts to create the table Specify the schema for the target table
  using the table_schema parameter.
  CREATE_NEVER: The write operation fails if the target table does not exist.
  """
  CREATE_IF_NEEDED = 'CREATE_IF_NEEDED'
  CREATE_NEVER = 'CREATE_NEVER'

  @staticmethod
  def VerifyParam(field):
    if field and not hasattr(CreateDisposition, field):
      raise RuntimeError(
          'Create disposition has to be one of the following values:'
          'CREATE_IF_NEEDED, CREATE_NEVER. Got: {}'.format(field))


class WriteDisposition:
  """
  Enum class for possible values of write dispositions:
  APPEND: Default behaviour. Written data is added to the existing rows
  in the table,
  EMPTY: The target table must be empty;  otherwise, the write operation fails,
  TRUNCATE: The write operation deletes all rows from the target table
  before writing to it.
  """
  APPEND = 'APPEND'
  EMPTY = 'EMPTY'
  TRUNCATE = 'TRUNCATE'

  @staticmethod

View on GitHub (pinned to 12126d8942)