{"record":{"id":"7504956dc127dc8a","repo":"apache/beam","slug":"unable-to-parse-value-s-as-s-for-snowflake-field-s","errorCode":null,"errorMessage":"Unable to parse value '%s' as %s for Snowflake field '%s'.","messagePattern":"Unable to parse value '(.+?)' as (.+?) for Snowflake field '(.+?)'\\.","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeSchemaTransformUtils.java","lineNumber":262,"sourceCode":"          throw new IllegalArgumentException(String.format(\"Invalid boolean value '%s'.\", value));\n\n        case BYTES:\n          return decodeHex(value);\n\n        case DATETIME:\n          return Instant.parse(value);\n\n        case DECIMAL:\n        case ARRAY:\n        case ITERABLE:\n        case MAP:\n        case ROW:\n        case LOGICAL_TYPE:\n        default:\n          throw unsupportedFieldType(field, null);\n      }\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Unable to parse value '%s' as %s for Snowflake field '%s'.\",\n              value, field.getType().getTypeName(), field.getName()),\n          e);\n    }\n  }\n\n  private static byte[] decodeHex(String value) {\n    if ((value.length() & 1) != 0) {\n      throw new IllegalArgumentException(\"Invalid hexadecimal Snowflake binary value.\");\n    }\n\n    byte[] result = new byte[value.length() / 2];\n\n    for (int i = 0; i < value.length(); i += 2) {\n      int high = Character.digit(value.charAt(i), 16);\n      int low = Character.digit(value.charAt(i + 1), 16);\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeSchemaTransformUtils.java#L244-L280","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped cause (the chained IllegalArgumentException) to see the exact parse failure and fix the data format accordingly.","Normalize formats in the SQL query (TO_NUMBER, TO_TIMESTAMP_NTZ, TO_CHAR with explicit format).","Loosen or correct the Beam schema field type to match the actual data format.","Catch IllegalArgumentException around toRow for graceful per-row error handling."],"exampleFix":"// before\nselect amount from sales; -- '1,234.56' parsed as INT64\n// after\nselect cast(replace(amount, ',', '') as int) as amount from sales;","handlingStrategy":"try-catch","validationCode":"try {\n  switch (typeName) { case INT64: Long.parseLong(value); break; case DATETIME: Instant.parse(value); break; /* ... */ }\n} catch (IllegalArgumentException e) { /* reject row early */ }","typeGuard":null,"tryCatchPattern":"try { Row r = SnowflakeSchemaTransformUtils.toRow(parts, schema); }\ncatch (IllegalArgumentException e) {\n  // e includes value, target type, and field name; cause has parser detail\n  routeToDeadLetter(parts, e);\n}","preventionTips":["Format values in SQL (TO_NUMBER, TO_TIMESTAMP, TO_CHAR) to canonical forms.","Keep Beam schema types aligned with actual Snowflake column types.","Handle bad rows with a dead-letter queue instead of failing the pipeline."],"tags":["java","snowflake","type-mismatch","parsing"],"backgroundTag":"type-mismatch","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"}