prestodb/presto · error · UnsupportedOperationException

explain analyze is not supported

Error message

explain analyze is not supported

What it means

Presto on Spark does not support EXPLAIN ANALYZE. In PrestoSparkModule.setup, the bound ExplainAnalyzeContext's query-id callback immediately throws UnsupportedOperationException('explain analyze is not supported'), because there is no per-task completion tracking on Spark yet (noted by the TODO). The query is planned but execution of EXPLAIN ANALYZE aborts.

Source

Thrown at presto-spark-base/src/main/java/com/facebook/presto/spark/PrestoSparkModule.java:539

        configBinder(binder).bindConfig(QueryMonitorConfig.class);
        binder.bind(SplitMonitor.class).in(Scopes.SINGLETON);

        // Determine the NodeVersion
        ServerConfig serverConfig = buildConfigObject(ServerConfig.class);
        NodeVersion nodeVersion = new NodeVersion(serverConfig.getPrestoVersion());
        binder.bind(NodeVersion.class).toInstance(nodeVersion);

        //Support DDL statements. Helper class binds DDL statements to DataDefinitionTasks
        PrestoDataDefBindingHelper.bindDDLDefinitionTasks(binder);

        // TODO: Decouple node specific system tables
        binder.bind(QueryManager.class).to(PrestoSparkQueryManager.class).in(Scopes.SINGLETON);
        binder.bind(TaskManager.class).to(PrestoSparkTaskManager.class).in(Scopes.SINGLETON);
        binder.install(new SystemConnectorModule());

        // TODO: support explain analyze for Spark
        binder.bind(new TypeLiteral<Optional<ExplainAnalyzeContext>>() {}).toInstance(Optional.of(new ExplainAnalyzeContext((queryId) -> {
            throw new UnsupportedOperationException("explain analyze is not supported");
        })));

        // TODO: support CBO, supply real nodes count
        binder.bind(TaskCountEstimator.class).toInstance(new TaskCountEstimator(() -> 1000));

        // TODO: Decouple and remove: required by ConnectorManager
        binder.bind(InternalNodeManager.class).toInstance(new PrestoSparkInternalNodeManager());
        binder.bind(PluginNodeManager.class).in(Scopes.SINGLETON);

        // TODO: Decouple and remove: required by PluginManager
        binder.bind(InternalResourceGroupManager.class).in(Scopes.SINGLETON);
        binder.bind(ResourceGroupManager.class).to(InternalResourceGroupManager.class);
        binder.bind(new TypeLiteral<ResourceGroupManager<?>>() {}).to(new TypeLiteral<InternalResourceGroupManager<?>>() {});
        binder.bind(ClusterMemoryPoolManager.class).toInstance(((poolId, listener) -> {}));
        binder.bind(QueryPrerequisitesManager.class).in(Scopes.SINGLETON);
        binder.bind(ResourceGroupService.class).to(NoopResourceGroupService.class).in(Scopes.SINGLETON);
        binder.bind(NodeTtlFetcherManager.class).to(ThrowingNodeTtlFetcherManager.class).in(Scopes.SINGLETON);
        binder.bind(ClusterTtlProviderManager.class).to(ThrowingClusterTtlProviderManager.class).in(Scopes.SINGLETON);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use plain EXPLAIN on Spark to inspect the plan without runtime statistics
  2. Run the query and inspect Presto Spark query/execution statistics from the Spark UI and query completion events instead
  3. Upgrade to a Presto Spark version that implements EXPLAIN ANALYZE support if/when available

Example fix

-- before
EXPLAIN ANALYZE SELECT count(*) FROM nation;
-- after
EXPLAIN SELECT count(*) FROM nation;
Defensive patterns

Strategy: fallback

Validate before calling

if (sql.trim().toUpperCase(Locale.ROOT).startsWith("EXPLAIN ANALYZE")) {
    throw new IllegalArgumentException("EXPLAIN ANALYZE is not supported on Presto on Spark; use EXPLAIN");
}

Try / catch

try {
    client.execute(sql);
} catch (UnsupportedOperationException e) {
    if (e.getMessage().contains("explain analyze is not supported")) {
        sql = sql.replaceFirst("(?i)EXPLAIN\\s+ANALYZE", "EXPLAIN");
        client.execute(sql);
    } else throw e;
}

Prevention

When it happens

Trigger: Running 'EXPLAIN ANALYZE <query>' against a Presto on Spark cluster (any statement submitted through PrestoSparkLauncher).

Common situations: Using the same BI tools/scripts against both a normal Presto cluster and Presto on Spark; validating query performance on Spark with EXPLAIN ANALYZE out of habit.

Related errors


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