{"record":{"id":"82473c770e6a8ff3","repo":"apache/beam","slug":"provided-length-s-is-bigger-than-max-length-s","errorCode":null,"errorMessage":"Provided length %s is bigger than max length %s ","messagePattern":"Provided length (.+?) is bigger than max length (.+?) ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/data/text/SnowflakeVarchar.java","lineNumber":42,"sourceCode":"  \"nullness\" // TODO(https://github.com/apache/beam/issues/20497)\n})\npublic class SnowflakeVarchar implements SnowflakeDataType, Serializable {\n  public static final Long MAX_LENGTH = 16777216L;\n  private Long length;\n\n  public static SnowflakeVarchar of() {\n    return new SnowflakeVarchar();\n  }\n\n  public static SnowflakeVarchar of(long length) {\n    return new SnowflakeVarchar(length);\n  }\n\n  public SnowflakeVarchar() {}\n\n  public SnowflakeVarchar(long length) {\n    if (length > MAX_LENGTH) {\n      throw new IllegalArgumentException(\n          String.format(\"Provided length %s is bigger than max length %s \", length, MAX_LENGTH));\n    }\n    this.length = length;\n  }\n\n  @Override\n  public String sql() {\n    if (length != null) {\n      return String.format(\"VARCHAR(%d)\", length);\n    }\n    return \"VARCHAR\";\n  }\n\n  public Long getLength() {\n    return length;\n  }\n\n  public void setLength(Long length) {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/data/text/SnowflakeVarchar.java#L24-L60","documentation":"SnowflakeVarchar(long) validates the declared VARCHAR length against MAX_LENGTH (Snowflake's maximum VARCHAR length, 4194304 characters). Lengths above the maximum are not representable by Snowflake's VARCHAR type, so the constructor throws an IllegalArgumentException.","triggerScenarios":"Calling new SnowflakeVarchar(length) or the equivalent factory with length > 4194304, e.g. when declaring a VARCHAR column of 'unlimited' size with a too-large sentinel value.","commonSituations":"Porting schemas from other databases where VARCHAR can be larger; using a placeholder like Long.MAX_VALUE to mean 'max length' instead of the Snowflake maximum.","solutions":["Use a length of at most 4194304, or use the no-arg SnowflakeVarchar() / VARCHAR default which Snowflake treats as maximum size.","Replace sentinel values like Long.MAX_VALUE with SnowflakeVarchar.MAX_LENGTH.","Adjust ported DDL definitions to Snowflake's VARCHAR limits."],"exampleFix":"// before\nnew SnowflakeVarchar(Long.MAX_VALUE)\n// after\nnew SnowflakeVarchar(SnowflakeVarchar.MAX_LENGTH)","handlingStrategy":"validation","validationCode":"if (length > SnowflakeVarchar.MAX_LENGTH) {\n  throw new IllegalArgumentException(\"length must be <= \" + SnowflakeVarchar.MAX_LENGTH);\n}","typeGuard":"static boolean isValidVarcharLength(long length) { return length >= 0 && length <= 4194304L; }","tryCatchPattern":"try {\n  SnowflakeVarchar col = new SnowflakeVarchar(length);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"bigger than max length\")) { col = new SnowflakeVarchar(); /* default max */ }\n  else throw e;\n}","preventionTips":["Use the no-arg SnowflakeVarchar() for maximum-size VARCHAR columns instead of large sentinel numbers.","Clamp ported DDL lengths to SnowflakeVarchar.MAX_LENGTH (4194304).","Keep column definitions in one constants class so limits are enforced centrally."],"tags":["java","snowflake","schema","validation"],"backgroundTag":"value-out-of-range","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"}