apache/beam · error · java.lang.IllegalArgumentException

Unable to parse value

Error message

Unable to parse value '%s' as %s for Snowflake field '%s'.

What it means

toBeamValue wraps its per-type parsing logic (Instant.parse, numeric parsing, etc.) in a catch of IllegalArgumentException and rethrows with a uniform message naming the raw value, the target Beam type name, and the field. It signals that a Snowflake string cell could not be converted to the declared schema type.

Solutions

  1. Read the wrapped cause (the chained IllegalArgumentException) to see the exact parse failure and fix the data format accordingly.
  2. Normalize formats in the SQL query (TO_NUMBER, TO_TIMESTAMP_NTZ, TO_CHAR with explicit format).
  3. Loosen or correct the Beam schema field type to match the actual data format.
  4. Catch IllegalArgumentException around toRow for graceful per-row error handling.

Example fix

// before
select amount from sales; -- '1,234.56' parsed as INT64
// after
select cast(replace(amount, ',', '') as int) as amount from sales;
Defensive patterns

Strategy: try-catch

Validate before calling

try {
  switch (typeName) { case INT64: Long.parseLong(value); break; case DATETIME: Instant.parse(value); break; /* ... */ }
} catch (IllegalArgumentException e) { /* reject row early */ }

Try / catch

try { Row r = SnowflakeSchemaTransformUtils.toRow(parts, schema); }
catch (IllegalArgumentException e) {
  // e includes value, target type, and field name; cause has parser detail
  routeToDeadLetter(parts, e);
}

Prevention

When it happens

Trigger: Any malformed cell for its declared type: non-numeric text in an INT64 field, an ISO-8601-incompatible timestamp in DATETIME, a non-hex string in BYTES, etc., passed through toRow.

Common situations: Locale-specific number formats (comma decimal separator); Snowflake TIMESTAMP_TZ rendering in a format Instant.parse rejects; schema changed to a stricter type after data was written; empty-but-not-null strings reaching numeric parsers.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeSchemaTransformUtils.java:262

          throw new IllegalArgumentException(String.format("Invalid boolean value '%s'.", value));

        case BYTES:
          return decodeHex(value);

        case DATETIME:
          return Instant.parse(value);

        case DECIMAL:
        case ARRAY:
        case ITERABLE:
        case MAP:
        case ROW:
        case LOGICAL_TYPE:
        default:
          throw unsupportedFieldType(field, null);
      }
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException(
          String.format(
              "Unable to parse value '%s' as %s for Snowflake field '%s'.",
              value, field.getType().getTypeName(), field.getName()),
          e);
    }
  }

  private static byte[] decodeHex(String value) {
    if ((value.length() & 1) != 0) {
      throw new IllegalArgumentException("Invalid hexadecimal Snowflake binary value.");
    }

    byte[] result = new byte[value.length() / 2];

    for (int i = 0; i < value.length(); i += 2) {
      int high = Character.digit(value.charAt(i), 16);
      int low = Character.digit(value.charAt(i + 1), 16);

View on GitHub (pinned to 12126d8942)