prestodb/presto · error · QueryPreprocessorException
Query preprocessor exited
Error message
Query preprocessor exited
What it means
QueryPreprocessorException thrown when the external preprocessor process terminates with a non-zero exit code. The CLI waits for the process, reads its stderr (with a 100ms timeout), and appends any captured stderr to the message to explain why the process failed.
Source
Thrown at presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java:174
}
}
catch (QueryPreprocessorException e) {
throw e;
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new QueryPreprocessorException("Interrupted while preprocessing query");
}
catch (Throwable e) {
throw new QueryPreprocessorException("Error preprocessing query: " + e.getMessage(), e);
}
// check we got a valid exit code
if (exitCode != 0) {
Optional<String> errorMessage = tryGetFutureValue(readStderr, 100, MILLISECONDS)
.flatMap(value -> Optional.ofNullable(emptyToNull(value.trim())));
throw new QueryPreprocessorException("Query preprocessor exited " + exitCode +
errorMessage.map(message1 -> "\n===\n" + message1 + "\n===").orElse(""));
}
return result;
});
try {
return task.get(timeout.toMillis(), MILLISECONDS);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new QueryPreprocessorException("Interrupted while preprocessing query");
}
catch (ExecutionException e) {
Throwable cause = e.getCause();
propagateIfPossible(cause, QueryPreprocessorException.class);
throw new QueryPreprocessorException("Error preprocessing query: " + cause.getMessage(), cause);
}
catch (TimeoutException e) {View on GitHub (pinned to 55bb57d202)
Solutions
- Read the stderr block (=== ... ===) appended to the message; it usually states the process failure.
- Run the preprocessor command manually against the same SQL to see the error.
- Fix the script's bugs/missing dependencies and ensure it exits 0 on success.
- Check the shebang line and PATH inside the environment the CLI runs in.
- If the preprocessor intentionally rejects queries, adjust its exit/protocol handling to match the expected contract.
Example fix
// before (script exits non-zero on heredoc quoting bug)
#!/usr/bin/env python3
main(sys.argv[1:])
// after
#!/usr/bin/env python3
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]) or 0) Defensive patterns
Strategy: try-catch
Validate before calling
// dry-run the preprocessor and check its exit code your-preprocessor.sh < sample.sql >/dev/null; echo $? # must be 0
Try / catch
try {
preprocessQuery(query);
} catch (QueryPreprocessorException e) {
if (e.getMessage().startsWith("Query preprocessor exited")) {
log.error("preprocessor process failed; stderr captured in message: {}", e.getMessage());
}
throw e;
} Prevention
- Make the preprocessor exit 0 on success and print errors to stderr.
- Fix shebangs and interpreter availability in the execution environment.
- Add a self-check mode to the preprocessor script.
- Version-pin and smoke-test the preprocessor in CI.
When it happens
Trigger: The command given via --preprocessor-command exits with a status != 0; any crash, shell error, or explicit exit failure in the preprocessor script while preprocessing a query.
Common situations: Preprocessor script references a missing interpreter (bad shebang); script hits an error on specific SQL syntax; missing dependencies in the preprocessor environment; preprocessor rejects the query text by design.
Related errors
- Error preprocessing query:
- Timed out waiting for query preprocessor after
- both --execute and --file specified
- Error reading from file %s: %s
- No console from which to read password
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/5bb3d72990569487.
Report an issue: GitHub.