{"record":{"id":"44bf3457b06c1541","repo":"pentaho/pentaho-kettle","slug":"trans-exception-errorcalculatingdaterange","errorCode":null,"errorMessage":"Trans.Exception.ErrorCalculatingDateRange","messagePattern":"Trans\\.Exception\\.ErrorCalculatingDateRange","errorType":"exception","errorClass":"KettleTransException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/Trans.java","lineNumber":2449,"sourceCode":"        }\n      }\n\n      // OK, now we have a date-range. See if we need to set a maximum!\n      if ( transMeta.getMaxDateDifference() > 0.0 && // Do we have a difference specified?\n        startDate.getTime() > Const.MIN_DATE.getTime() ) { // Is the startdate > Minimum?\n        // See if the end-date is larger then Start_date + DIFF?\n        Date maxdesired = new Date( startDate.getTime() + ( (long) transMeta.getMaxDateDifference() * 1000 ) );\n\n        // If this is the case: lower the end-date. Pick up the next 'region' next time around.\n        // We do this to limit the workload in a single update session (e.g. for large fact tables)\n        //\n        if ( endDate.compareTo( maxdesired ) > 0 ) {\n          endDate = maxdesired;\n        }\n      }\n\n    } catch ( KettleException e ) {\n      throw new KettleTransException( BaseMessages.getString( PKG, \"Trans.Exception.ErrorCalculatingDateRange\",\n        logTable ), e );\n    }\n\n    // Be careful, We DO NOT close the trans log table database connection!!!\n    // It's closed later in beginProcessing() to prevent excessive connect/disconnect repetitions.\n\n  }\n\n  /**\n   * Begin processing. Also handle logging operations related to the start of the transformation\n   *\n   * @throws KettleTransException the kettle trans exception\n   */\n  public void beginProcessing() throws KettleTransException {\n    TransLogTable transLogTable = transMeta.getTransLogTable();\n    int intervalInSeconds = Const.toInt( environmentSubstitute( transLogTable.getLogInterval() ), -1 );\n\n    try {","sourceCodeStart":2431,"sourceCodeEnd":2467,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/Trans.java#L2431-L2467","documentation":"Thrown by Trans.beginProcessing() when calculating the transformation log table's date range fails with a generic KettleException. Kettle computes start/end dates (e.g. from the log table's previous records and a max date) so it can delete or expire old log rows before the run. Any database failure during that calculation (query, connection, schema issue) is wrapped in this exception.","triggerScenarios":"beginProcessing() calls the date-range calculation against the transformation LogTableConnectionInfo; the underlying SQL/round-trip throws KettleException, which is rethrown as KettleTransException(ErrorCalculatingDateRange, logTable).","commonSituations":"Transformation log table points to a database whose log table was dropped or altered (missing ID_*/LOG_DATE columns); database unreachable mid-startup; DB user lacking SELECT/DELETE privileges on the log table; date conversion issues with unusual DB date formats/timezones.","solutions":["Inspect the chained 'cause' exception to find the underlying SQL error and fix it first (connection, missing table, privileges).","Verify the transformation log table exists in the target database with the expected schema; run 'SQL' generation in the Log tab or recreate the table.","Test the configured database connection (Test button) and confirm the user has read/delete rights on the log table.","Check date format/locale settings on the database connection if the cause shows date parsing failures."],"exampleFix":"// before: log table missing -> cause: table not found\nLog table: trans_log (connection ETL_DB)\n// after: create the log table via the Log tab 'SQL' button or DDL\nCREATE TABLE trans_log (ID_BATCH INTEGER, CHANNEL_ID VARCHAR(255), LOG_DATE TIMESTAMP, ...);","handlingStrategy":"validation","validationCode":"// Verify the trans log table exists and is queryable before beginProcessing\nDatabase db = new Database(trans, logTable.getDatabaseMeta());\ndb.connect();\nDatabaseMetaData md = db.getConnection().getMetaData();\nResultSet rs = md.getTables(null, null, \"TRANS_LOG\", null);\nif (!rs.next()) throw new IllegalStateException(\"trans_log table missing\");","typeGuard":null,"tryCatchPattern":"try {\n  trans.beginProcessing();\n} catch (KettleTransException e) {\n  if (e.getCause() instanceof KettleException) {\n    log.error(\"Date-range calc failed on log table: check cause\", e.getCause());\n  }\n}","preventionTips":["Generate and version-control log table DDL alongside the transformation.","Test the log table connection after any DB maintenance or upgrade.","Confirm the log user has SELECT and DELETE on log tables before deployments."],"tags":["database","logging","transformation","sql"],"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"}