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

  1. Inspect the full stack trace: the cause attached to this exception names the real failure.
  2. Run the preprocessor command manually with a sample query to reproduce the failure.
  3. Verify the preprocessor executable exists, is executable, and works with the installed JVM.
  4. Fix or update the preprocessor script; if preprocessing is not needed, remove --preprocessor-command.
  5. 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

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


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/31e41ffdc200941d. Report an issue: GitHub.