{"record":{"id":"94bdaeb9d78da214","repo":"apache/iceberg","slug":"database-data-truncation-error-94bdae","errorCode":null,"errorMessage":"Database data truncation error","messagePattern":"Database data truncation error","errorType":"exception","errorClass":"UncheckedSQLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java","lineNumber":119,"sourceCode":"          JdbcUtil.loadView(JdbcUtil.SchemaVersion.V1, connections, catalogName, viewIdentifier);\n      if (base != null) {\n        validateMetadataLocation(view, base);\n        String oldMetadataLocation = base.metadataFileLocation();\n        // Start atomic update\n        LOG.debug(\"Committing existing view: {}\", viewName());\n        updateView(newMetadataLocation, oldMetadataLocation);\n      } else {\n        // view does not exist, create it\n        LOG.debug(\"Committing new view: {}\", viewName());\n        createView(newMetadataLocation);\n      }\n\n    } catch (SQLTimeoutException e) {\n      throw new UncheckedSQLException(e, \"Database Connection timeout\");\n    } catch (SQLTransientConnectionException | SQLNonTransientConnectionException e) {\n      throw new UncheckedSQLException(e, \"Database Connection failed\");\n    } catch (DataTruncation e) {\n      throw new UncheckedSQLException(e, \"Database data truncation error\");\n    } catch (SQLWarning e) {\n      throw new UncheckedSQLException(e, \"Database warning\");\n    } catch (SQLException e) {\n      if (JdbcUtil.isConstraintViolation(e)) {\n        if (currentMetadataLocation() == null) {\n          throw new AlreadyExistsException(e, \"View already exists: %s\", viewIdentifier);\n        } else {\n          throw new UncheckedSQLException(e, \"View already exists: %s\", viewIdentifier);\n        }\n      }\n\n      throw new UncheckedSQLException(e, \"Unknown failure\");\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new UncheckedInterruptedException(e, \"Interrupted during commit\");\n    }\n  }\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java#L101-L137","documentation":"Thrown by JdbcViewOperations.doCommit when a java.sql.DataTruncation occurs — a value being written (typically the metadata location string or catalog row columns) exceeded the column size in the database. Wrapped in UncheckedSQLException. The commit did not succeed.","triggerScenarios":"Committing a view whose metadata file location or other row values exceed the length of iceberg_views columns; often after deeply nested warehouse paths or very long identifiers.","commonSituations":"JDBC catalog initialized with a schema that has short VARCHAR columns (or older schema versions), extremely long S3/GCS paths or namespace/table names pushing locations past column limits.","solutions":["Widen the offending catalog table columns (e.g. increase VARCHAR length for metadata location) and retry","Shorten the warehouse path or identifiers so metadata locations fit existing column limits","Recreate the catalog tables using the current recommended Iceberg JDBC schema","Inspect the DataTruncation cause to identify which column/parameter was truncated"],"exampleFix":"// before\nCREATE TABLE iceberg_views (... metadata_location VARCHAR(255) ...);\n// after\nALTER TABLE iceberg_views ALTER COLUMN metadata_location TYPE VARCHAR(2048);","handlingStrategy":"validation","validationCode":"// Ensure metadata location fits catalog column limits\nString loc = metadataFileLocation();\nPreconditions.checkArgument(loc.length() <= 2048,\n    \"Metadata location too long for catalog columns: %s\", loc.length());","typeGuard":null,"tryCatchPattern":"try {\n  view.updateSchema(apply);\n} catch (UncheckedSQLException e) {\n  if (e.getCause() instanceof DataTruncation) {\n    // widen columns or shorten paths, then retry\n  } else throw e;\n}","preventionTips":["Create catalog tables with generous column sizes for locations","Keep warehouse paths and identifiers reasonably short","Use the current Iceberg JDBC schema scripts when initializing"],"tags":["jdbc","sql","schema"],"backgroundTag":"database-write-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}