{"record":{"id":"b4372bf7de0276a2","repo":"apache/iceberg","slug":"cannot-parse-order-parser-is-not-an-iceberg-exten","errorCode":null,"errorMessage":"Cannot parse order: parser is not an Iceberg ExtendedParser","messagePattern":"Cannot parse order: parser is not an Iceberg ExtendedParser","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/ExtendedParser.java","lineNumber":67,"sourceCode":"      return direction;\n    }\n\n    public NullOrder nullOrder() {\n      return nullOrder;\n    }\n  }\n\n  static List<RawOrderField> parseSortOrder(SparkSession spark, String orderString) {\n    ExtendedParser extParser = findParser(spark.sessionState().sqlParser(), ExtendedParser.class);\n    if (extParser != null) {\n      try {\n        return extParser.parseSortOrder(orderString);\n      } catch (AnalysisException e) {\n        throw new IllegalArgumentException(\n            String.format(\"Unable to parse sortOrder: %s\", orderString), e);\n      }\n    } else {\n      throw new IllegalStateException(\n          \"Cannot parse order: parser is not an Iceberg ExtendedParser\");\n    }\n  }\n\n  private static <T> T findParser(ParserInterface parser, Class<T> clazz) {\n    ParserInterface current = parser;\n    while (current != null) {\n      if (clazz.isInstance(current)) {\n        return clazz.cast(current);\n      }\n\n      current = getNextDelegateParser(current);\n    }\n\n    return null;\n  }\n\n  private static ParserInterface getNextDelegateParser(ParserInterface parser) {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/ExtendedParser.java#L49-L85","documentation":"When Spark session's SQL parser is not (wrapping) Iceberg's ExtendedParser, parseSortOrder cannot parse order strings and throws IllegalStateException('Cannot parse order: parser is not an Iceberg ExtendedParser'). ExtendedParser is contributed by the Iceberg Spark extensions, so this indicates the extensions/parser plugin isn't active in the session.","triggerScenarios":"Calling parseSortOrder (or SQL like ALTER TABLE ... WRITE ORDERED BY) in a SparkSession where the Iceberg SparkSessionExtensions were never injected, or a custom ParserInterface replaced the default without extending ExtendedParser.","commonSituations":"Missing .config('spark.sql.extensions', 'org.apache.iceberg.spark.SparkSessionExtensions'); spark-sql without the iceberg runtime jar configured; another catalog/parser extension overriding the SQL parser chain.","solutions":["Set spark.sql.extensions=org.apache.iceberg.spark.SparkSessionExtensions in the Spark config and include the iceberg-spark runtime jar on the classpath.","Check spark.sql.catalog.<name> points at the Iceberg catalog and extensions are applied to the correct session.","If a third-party parser plugin is installed, ensure it wraps or falls through to Iceberg's ExtendedParser (findParser walks the delegation chain).","Alternatively compute sort orders via the Iceberg Java API (SortOrder.builderFor(schema)...) instead of string parsing."],"exampleFix":"// before\nspark = SparkSession.builder().appName(\"job\").getOrCreate(); // no Iceberg extensions\n// after\nspark = SparkSession.builder()\n    .appName(\"job\")\n    .config(\"spark.sql.extensions\", \"org.apache.iceberg.spark.SparkSessionExtensions\")\n    .getOrCreate();","handlingStrategy":"validation","validationCode":"boolean ok = spark.conf().get(\"spark.sql.extensions\", \"\")\n    .contains(\"org.apache.iceberg.spark.SparkSessionExtensions\");\nif (!ok) throw new IllegalStateException(\"Iceberg Spark extensions not configured\");","typeGuard":null,"tryCatchPattern":"try { parseSortOrder(spark, orderString); } catch (IllegalStateException e) { throw new ConfigException(\"Enable Iceberg SparkSessionExtensions to parse sort orders\", e); }","preventionTips":["Always set spark.sql.extensions to include SparkSessionExtensions when using Iceberg SQL features","Keep the iceberg-spark runtime jar on the driver and executor classpath","Avoid third-party parser plugins that bypass the Iceberg ExtendedParser chain"],"tags":["spark","parser","configuration"],"backgroundTag":"missing-config-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}