{"record":{"id":"a2f2961400bacafc","repo":"apache/iceberg","slug":"e-message","errorCode":null,"errorMessage":"${e.message}","messagePattern":"\\$\\{e\\.message\\}","errorType":"exception","errorClass":"IcebergParseException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSparkSqlExtensionsParser.scala","lineNumber":224,"sourceCode":"      } catch {\n        case _: ParseCancellationException =>\n          // if we fail, parse with LL mode with DefaultErrorStrategy\n          tokenStream.seek(0) // rewind input stream\n          parser.reset()\n\n          // Try Again.\n          parser.setErrorHandler(new DefaultErrorStrategy)\n          parser.getInterpreter.setPredictionMode(PredictionMode.LL)\n          toResult(parser)\n      }\n    } catch {\n      case e: IcebergParseException if e.command.isDefined =>\n        throw e\n      case e: IcebergParseException =>\n        throw e.withCommand(command)\n      case e: AnalysisException =>\n        val position = Origin(e.line, e.startPosition)\n        throw new IcebergParseException(Option(command), e.message, position, position)\n    }\n  }\n\n  override def parseQuery(sqlText: String): LogicalPlan = {\n    parsePlan(sqlText)\n  }\n}\n\nobject IcebergSparkSqlExtensionsParser {\n  private val substitutorCtor: DynConstructors.Ctor[VariableSubstitution] =\n    DynConstructors\n      .builder()\n      .impl(classOf[VariableSubstitution])\n      .impl(classOf[VariableSubstitution], classOf[SQLConf])\n      .build()\n}\n\n/* Copied from Apache Spark's to avoid dependency on Spark Internals */","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSparkSqlExtensionsParser.scala#L206-L242","documentation":"This is the parser's error-forwarding path: when a statement fails with an IcebergParseException or a Spark AnalysisException during parsing, the parser rethrows it, attaching the original SQL command text so the error message can show a code snippet with a caret pointing at the failing position. It wraps any AnalysisException coming from extended grammar handling into an IcebergParseException with the command attached.","triggerScenarios":"Executing any Iceberg-extended SQL statement (ALTER TABLE ... SET TBLPROPERTIES, CALL, ADD PARTITION FIELD, etc.) through SparkSession.sql where the statement fails to parse or a nested AnalysisException is raised during the parse phase.","commonSituations":"Typos in Iceberg SQL extensions syntax, using a clause unsupported by the configured extensions parser, quoting/escaping mistakes in SQL strings, or running Iceberg SQL on a Spark session that partially registers the extensions.","solutions":["Read the attached command snippet and caret position to locate the syntax problem and fix the SQL text.","Verify org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions is listed in spark.sql.extensions.","Check the Iceberg/Spark version pairing; grammar differs between versions.","If it is an AnalysisException (not a syntax problem), the table or catalog referenced likely does not exist or is not Iceberg."],"exampleFix":"// before\nspark.sql(\"ALTER TABLE t WRITE ORDERED BY nonexistent_col\")\n// after\nspark.sql(\"ALTER TABLE t WRITE ORDERED BY id\")  // fix column/syntax per the caret in the error","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Scala\ntry { spark.sql(stmt) } catch {\n  case e: org.apache.iceberg.spark.sql.IcebergParseException if e.line.isDefined =>\n    log.error(s\"Parse failed near line ${e.line.get}: ${e.message}\")\n}","preventionTips":["Keep IcebergSparkSessionExtensions configured in spark.sql.extensions.","Lint SQL with a parser that knows the Iceberg extensions grammar.","Match Iceberg and Spark versions carefully.","Test generated SQL against a staging session before production."],"tags":["spark-sql","parser","syntax-error"],"backgroundTag":"invalid-argument-format","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}