{"record":{"id":"576193c12d2f50ce","repo":"prestodb/presto","slug":"coordinator-only-fragment-execution-is-not-support","errorCode":null,"errorMessage":"Coordinator only fragment execution is not supported by native task executor","messagePattern":"Coordinator only fragment execution is not supported by native task executor","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-spark-base/src/main/java/com/facebook/presto/spark/execution/task/PrestoSparkNativeTaskExecutorFactory.java","lineNumber":292,"sourceCode":"\n        Session session = taskDescriptor.getSession().toSession(\n                sessionPropertyManager,\n                taskDescriptor.getExtraCredentials(),\n                extraAuthenticators.build());\n        PlanFragment fragment = taskDescriptor.getFragment();\n        StageId stageId = new StageId(session.getQueryId(), fragment.getId().getId());\n        TaskId taskId = new TaskId(new StageExecutionId(stageId, 0), partitionId, attemptNumber);\n\n        // TODO: Remove this once we can display the plan on Spark UI.\n        // Currently, `textPlanFragment` throws an exception if json-based UDFs are used in the query, which can only\n        // happen in native execution mode. To resolve this error, `JsonFileBasedFunctionNamespaceManager` must be\n        // loaded on the executors as well (which is actually not required for native execution). To do so, we need a\n        // mechanism to ship the JSON file containing the UDF metadata to workers, which does not exist as of today.\n        // TODO: Address this issue; more details in https://github.com/prestodb/presto/issues/19600\n        log.info(\"Logging plan fragment is not supported for presto-on-spark native execution, yet\");\n\n        if (fragment.getPartitioning().isCoordinatorOnly()) {\n            throw new UnsupportedOperationException(\"Coordinator only fragment execution is not supported by native task executor\");\n        }\n\n        checkArgument(\n                inputs instanceof PrestoSparkNativeTaskInputs,\n                format(\"PrestoSparkNativeTaskInputs is required for native execution, but %s is provided\", inputs.getClass().getName()));\n\n        // 1. Start the native process if it hasn't already been started or dead\n        createAndStartNativeExecutionProcess(session, nativeTempStorageHandle);\n\n        // 2. compute the task info to send to cpp process\n        PrestoSparkNativeTaskInputs nativeInputs = (PrestoSparkNativeTaskInputs) inputs;\n\n        // 2.a Populate Read info\n        List<TaskSource> taskSources = getTaskSources(serializedTaskSources, fragment, session, nativeInputs);\n\n        // 2.b Populate Shuffle Write info\n        Optional<PrestoSparkShuffleWriteInfo> shuffleWriteInfo = nativeInputs.getShuffleWriteDescriptor()\n                .map(descriptor -> shuffleInfoTranslator.createShuffleWriteInfo(session, descriptor));","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/task/PrestoSparkNativeTaskExecutorFactory.java#L274-L310","documentation":"The native (Velox C++) task executor for Presto on Spark cannot execute coordinator-only fragments (e.g. final aggregation/limit stages that run only on the coordinator). doCreate checks fragment.getPartitioning().isCoordinatorOnly() and refuses such plans with UnsupportedOperationException. Coordinator-only fragments are normally executed on the Java driver, so routing them to a native worker is unsupported.","triggerScenarios":"Running a query whose plan contains a coordinator-only fragment (e.g. a final aggregation stage or LIMIT) with Presto on Spark native execution enabled (native task executor factory PrestoSparkNativeTaskExecutorFactory.doCreate).","commonSituations":"Operators enabling --native-execution on Spark clusters whose queries finish with coordinator-only final stages; mixing native and coordinator-distributed partitionings; upgrading to native execution while relying on queries with final aggregation stages.","solutions":["Disable native execution for queries/fragments that produce coordinator-only stages (use the Java task executor factory)","Rewrite the query to avoid coordinator-only stages, e.g. use GROUP BY / partitioned aggregation or remove LIMIT patterns that force coordinator-only execution","Check the plan (EXPLAIN) for coordinator-only fragments before enabling native execution","Track https://github.com/prestodb/presto/issues/19600 for coordinator-only fragment support in native execution"],"exampleFix":"// before\nquerySession.setSystemProperty(PRESTO_SPARK_NATIVE_EXECUTION_ENABLED, \"true\");\n// after (fallback for coordinator-only fragments)\nif (fragment.getPartitioning().isCoordinatorOnly()) {\n    taskExecutorFactory = javaTaskExecutorFactory; // use Java executor\n} else {\n    taskExecutorFactory = nativeTaskExecutorFactory;\n}","handlingStrategy":"validation","validationCode":"if (fragment.getPartitioning().isCoordinatorOnly() && nativeExecutionEnabled) {\n    throw new PrestoException(NOT_SUPPORTED, \"query has coordinator-only fragment; disable native execution\");\n}","typeGuard":"boolean isCoordinatorOnly(PlanFragment f) { return f.getPartitioning() != null && f.getPartitioning().isCoordinatorOnly(); }","tryCatchPattern":"try { taskExecutorFactory.create(...) } catch (UnsupportedOperationException e) { log.warn(\"falling back to java executor\"); return javaFactory.create(...); }","preventionTips":["Run EXPLAIN to detect coordinator-only fragments before enabling native execution","Default to the Java executor until issue #19600 (UDF/native coordinator-only support) is resolved","Keep native-execution rollouts gated per query workload"],"tags":["presto-on-spark","native-execution","unsupported-operation","coordinator-only-fragment"],"backgroundTag":"unsupported-native-execution-fragment","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}