{"record":{"id":"5ba77fd57850ddb4","repo":"pentaho/pentaho-kettle","slug":"unable-to-create-or-modify-table-schematable","errorCode":null,"errorMessage":"Unable to create or modify table {schemaTable}","messagePattern":"Unable to create or modify table (.+?)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/KettleDatabaseRepositoryCreationHelper.java","lineNumber":140,"sourceCode":"      KettleDatabaseRepository.REP_STRING_LENGTH, 0 ) );\n    sql =\n      database.getDDL(\n        schemaTable, table, null, false, KettleDatabaseRepository.FIELD_REPOSITORY_LOG_ID_REPOSITORY_LOG,\n        false );\n\n    if ( !Utils.isEmpty( sql ) ) {\n      statements.add( sql );\n      if ( !dryrun ) {\n        try {\n          if ( log.isDetailed() ) {\n            log.logDetailed( \"executing SQL statements: \" + Const.CR + sql );\n          }\n          database.execStatements( sql );\n          if ( log.isDetailed() ) {\n            log.logDetailed( \"Created/altered table \" + schemaTable );\n          }\n        } catch ( KettleException dbe ) {\n          throw new KettleException( \"Unable to create or modify table \" + schemaTable, dbe );\n        }\n      }\n    } else {\n      if ( log.isDetailed() ) {\n        log.logDetailed( \"Table \" + schemaTable + \" is OK.\" );\n      }\n    }\n\n    if ( !dryrun ) {\n      repository.insertLogEntry( ( upgrade ? \"Upgrade\" : \"Creation\" ) + \" of the Kettle repository\" );\n    }\n\n    // ////////////////////////////////////////////////////////////////////////////////\n    // R_VERSION\n    //\n    // Let's start with the version table\n    //\n    table = new RowMeta();","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/KettleDatabaseRepositoryCreationHelper.java#L122-L158","documentation":"createRepositorySchema() executes generated DDL for each required repository table via database.execStatements(sql); if the database throws a KettleException the helper wraps it as 'Unable to create or modify table <schemaTable>'. This occurs during repository connect-with-upgrade/create flows.","triggerScenarios":"Calling KettleDatabaseRepository.connect()/createRepositorySchema (indirectly from testCreateIndexLenghts, testDatabaseRepository, setUpBeforeClass) when CREATE/ALTER TABLE fails — insufficient privileges, unsupported SQL for the target database dialect, or the table exists in an incompatible state.","commonSituations":"First-time repository creation against a database user without DDL rights; unsupported/older database dialect producing invalid generated SQL; partially created repository from a previous failed run.","solutions":["Grant CREATE/ALTER TABLE privileges to the repository database user.","Check the nested KettleException/database error for the exact SQL failure and fix the dialect issue.","Drop or repair the partially created repository table and re-run creation.","Use a supported database type/version for the Kettle database repository."],"exampleFix":"// before\nrepo.connect(repoMeta); // auto-creates schema, fails on DDL privilege\n// after\nif (!database.checkTableExists(TABLE_R_VERSION)) {\n  grantDdlPrivileges(repoUser); // ensure CREATE TABLE allowed\n}\nrepo.connect(repoMeta);","handlingStrategy":"validation","validationCode":"DatabaseMeta db = repoMeta.getConnection();\nif (!db.testConnection()) throw new IllegalStateException(\"repository DB unreachable\");\n// user needs CREATE/ALTER privileges on the schema","typeGuard":null,"tryCatchPattern":"try {\n  repo.createRepositorySchema(monitor, false);\n} catch (KettleException e) {\n  log.error(\"table creation failed: \" + e.getCause(), e);\n}","preventionTips":["Grant DDL privileges to the repository user before first connect.","Use supported database versions/dialects only.","Test the connection before creating the schema.","Clean up partial schemas from failed runs."],"tags":["database","ddl","repository-creation"],"backgroundTag":"sql-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}