prestodb/presto · error · PrestoException

WARNING_AS_ERROR

WARNING_AS_ERROR

Error message

%s

What it means

When the WarningHandlingLevel is AS_ERROR (a session or system warnings-as-errors mode), DefaultWarningCollector.add throws PrestoException(WARNING_AS_ERROR) for any warning other than PARSER_WARNING, converting the first non-parser warning into a hard query failure. The thrown message is the warning's own toString(), so the actual cause is embedded in the exception message. Parser warnings are exempt so QueryPreparer can collect and throw them all at once during prepareQuery.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/warnings/DefaultWarningCollector.java:66

    @Override
    public synchronized void add(PrestoWarning warning)
    {
        requireNonNull(warning, "warning is null");
        switch (warningHandlingLevel) {
            case SUPPRESS:
                break;
            case NORMAL:
                addWarningIfNumWarningsLessThanConfig(warning);
                break;
            case AS_ERROR:
                /* Parser warnings must be handled differently since we should not throw an exception when parsing.
                 * Warnings are collected and an exception with all warnings is thrown in {@link QueryPreparer#prepareQuery}
                 */
                if (warning.getWarningCode() == PARSER_WARNING.toWarningCode()) {
                    addWarningIfNumWarningsLessThanConfig(warning);
                }
                else {
                    throw new PrestoException(WARNING_AS_ERROR, warning.toString());
                }
        }
    }

    @Override
    public synchronized List<PrestoWarning> getWarnings()
    {
        return ImmutableList.copyOf(warnings.values());
    }

    private synchronized void addWarningIfNumWarningsLessThanConfig(PrestoWarning warning)
    {
        if (warnings.size() < config.getMaxWarnings()) {
            warnings.put(warning.getWarningCode(), warning);
        }
    }

    @Override

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the exception message - it is warning.toString() - and fix the underlying condition that produced the warning (deprecation, metadata issue, etc.).
  2. Set the session property warning-handling-level=NORMAL to collect warnings instead of failing.
  3. Change the coordinator config warning-handling.level from AS_ERROR to NORMAL if strict mode is not needed cluster-wide.
  4. If a specific plugin/connector emits the offending warning, upgrade or patch it so it uses PARSER_WARNING or stops emitting it.

Example fix

-- before: query fails with WARNING_AS_ERROR
SET SESSION warning_handling_level = 'AS_ERROR';
SELECT ...

-- after
SET SESSION warning_handling_level = 'NORMAL';
SELECT ...
Defensive patterns

Strategy: try-catch

Validate before calling

// Before running, ensure the session won't fail on warnings
String level = session.getSystemProperty("warning_handling_level", String.class);
if ("AS_ERROR".equals(level)) {
    log.warn("Warnings will abort this query; set warning_handling_level=NORMAL to tolerate them");
}

Try / catch

try {
    queryRunner.execute(query);
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("WARNING_AS_ERROR")) {
        // the message contains warning.toString(); log and rerun with NORMAL level
        log.warn("Query aborted by warning-as-errors mode: " + e.getMessage());
        return executeWithWarningLevel(query, "NORMAL");
    }
    throw e;
}

Prevention

When it happens

Trigger: A query runs with warning handling set to AS_ERROR (session property warning-handling-level=AS_ERROR or system config warning-handling.level=AS_ERROR) and execution emits any non-parser warning - e.g. deprecated connector behavior, Hive metadata warnings, or runtime deprecation notices.

Common situations: CI regression gates configured with warnings-as-errors catching a newly emitted deprecation warning after a connector/Presto upgrade; strict production settings where any warning (e.g. orphan-file or metadata warnings) now aborts queries; a plugin emitting a non-parser warning that was previously only informational.

Related errors


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