prestodb/presto · error · QueryPreprocessorException
Error preprocessing query:
Error message
Error preprocessing query:
What it means
QueryPreprocessorException thrown by the CLI's internal query preprocessor when any Throwable escapes the preprocessor execution. The message wraps the underlying exception's getMessage() (may be empty), and the original is attached as the cause. The preprocessor runs a user-supplied command that rewrites the SQL text before it is sent to the server.
Source
Thrown at presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java:166
// wait for process to finish
exitCode = process.waitFor();
}
finally {
process.destroyForcibly();
if (writeOutput != null) {
writeOutput.cancel(true);
}
}
}
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();View on GitHub (pinned to 55bb57d202)
Solutions
- Inspect the full stack trace: the cause attached to this exception names the real failure.
- Run the preprocessor command manually with a sample query to reproduce the failure.
- Verify the preprocessor executable exists, is executable, and works with the installed JVM.
- Fix or update the preprocessor script; if preprocessing is not needed, remove --preprocessor-command.
- Wrap your preprocessor so it exits 0 or produces a clear error message instead of throwing.
Example fix
// before ./presto --server localhost:8080 --preprocessor-command ./my-flaky-preprocessor.sh // after ./my-flaky-preprocessor.sh < sample.sql # test first; fix or drop the flag ./presto --server localhost:8080 --preprocessor-command ./my-fixed-preprocessor.sh
Defensive patterns
Strategy: try-catch
Validate before calling
// before invoking the CLI if [ ! -x "$PREPROCESSOR_CMD" ]; then echo "preprocessor missing: $PREPROCESSOR_CMD" >&2; exit 1; fi
Try / catch
try {
preprocessQuery(query);
} catch (QueryPreprocessorException e) {
Throwable cause = e.getCause();
log.error("preprocessor failed", cause != null ? cause : e);
throw e;
} Prevention
- Test the preprocessor command standalone with representative SQL before wiring it into the CLI.
- Keep the preprocessor dependency-free and fast.
- Remove --preprocessor-command when not needed.
- Log the full cause chain, since the top-level message may be empty.
When it happens
Trigger: Running the Presto CLI with --preprocessor-command where the external preprocessor process throws/returns an error; any RuntimeException or Error thrown inside the preprocessor task during preprocessQueryInternal.
Common situations: Misconfigured preprocessor script that crashes on certain SQL; preprocessor binary missing/incompatible causing an unexpected exception; JVM errors (OOM) during preprocessing; network/IO exceptions inside the preprocessor pipeline.
Related errors
- Query preprocessor exited
- 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/31e41ffdc200941d.
Report an issue: GitHub.