apache/dolphinscheduler · error · RuntimeException

sql file not found

Error message

sql file not found 

What it means

In UpgradeDao.upgradeDolphinSchedulerDML, if the DML script file (e.g. dolphinscheduler_dml.sql in the schema upgrade directory) cannot be found, the FileNotFoundException is rethrown as RuntimeException 'sql file not found '. Note the log message incorrectly says 'DDL file' even though this is the DML path.

Source

Thrown at dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/upgrader/UpgradeDao.java:119

                String upgradeSQL;
                if (databaseDialect.tableExists(T_VERSION_NAME)) {
                    // Change version in the version table to the new version
                    upgradeSQL = String.format("update %s set version = ?", T_VERSION_NAME);
                } else if (databaseDialect.tableExists(T_NEW_VERSION_NAME)) {
                    // Change version in the version table to the new version
                    upgradeSQL = String.format("update %s set version = ?", T_NEW_VERSION_NAME);
                } else {
                    throw new RuntimeException("The version table does not exist");
                }
                try (PreparedStatement pstmt = connection.prepareStatement(upgradeSQL)) {
                    pstmt.setString(1, schemaVersion);
                    pstmt.executeUpdate();
                }
            }
            log.info("Success execute the dml file, schemaDir:  {}, ddlScript: {}", schemaDir, scriptFile);
        } catch (FileNotFoundException e) {
            log.error("Cannot find the DDL file, schemaDir:  {}, ddlScript: {}", schemaDir, scriptFile, e);
            throw new RuntimeException("sql file not found ", e);
        } catch (Exception e) {
            log.error("Execute ddl file failed, meet an unknown exception, schemaDir:  {}, ddlScript: {}", schemaDir,
                    scriptFile, e);
            throw new RuntimeException("Execute ddl file failed, meet an unknown exception", e);
        }
    }

    /**
     * upgradeDolphinScheduler DDL
     *
     * @param schemaDir schemaDir
     */
    public void upgradeDolphinSchedulerDDL(String schemaDir, String scriptFile) {
        String sqlFilePath =
                String.format("sql/upgrade/%s/%s/%s", schemaDir, dbType.getDb(), scriptFile);
        SqlScriptRunner sqlScriptRunner = new SqlScriptRunner(dataSource, sqlFilePath);
        try {
            // Execute the dolphinscheduler ddl.sql for the upgrade

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the log line 'Cannot find the DDL file...' for the exact schemaDir and scriptFile path, and confirm the file exists there.
  2. Reinstall/repair the DolphinScheduler tools distribution so all sql upgrade directories are present.
  3. Verify schemaList matches the directories actually shipped under dolphinscheduler-datasource-api resources (dolphinscheduler_dml.sql present).
  4. Run the tool from the installed distribution root so relative sql paths resolve.
Defensive patterns

Strategy: validation

Validate before calling

// before upgrading, confirm the DML resource exists for the target version dir
String path = "dolphinscheduler-datasource-.../" + schemaDir + "/dolphinscheduler_dml.sql";
if (getClass().getClassLoader().getResource(path) == null) {
    throw new IllegalStateException("Missing DML upgrade script: " + path);
}

Try / catch

try {
    manager.upgradeDolphinScheduler();
} catch (RuntimeException e) {
    if (e.getMessage().contains("sql file not found")) {
        log.error("Upgrade script missing - check schemaDir contents and reinstall the distribution", e);
    } else throw e;
}

Prevention

When it happens

Trigger: Calling upgradeDolphinSchedulerDML with a schemaDir that does not contain the expected DML sql file — wrong schema directory name in schemaList, missing packaged sql resources, or a typo'd scriptFile path.

Common situations: Incomplete deployment jar missing dolphinscheduler_dml.sql; upgrading from a version whose schema directory was removed or renamed; running the tool from a working directory lacking the sql resources on the classpath.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/b48ff7423df2157c. Report an issue: GitHub.