{"record":{"id":"6836890aa66fb39d","repo":"apache/iceberg","slug":"msg-683689","errorCode":null,"errorMessage":"${msg}","messagePattern":"\\$\\{msg\\}","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":316,"sourceCode":"case object IcebergParseErrorListener extends BaseErrorListener {\n  override def syntaxError(\n      recognizer: Recognizer[_, _],\n      offendingSymbol: scala.Any,\n      line: Int,\n      charPositionInLine: Int,\n      msg: String,\n      e: RecognitionException): Unit = {\n    val (start, stop) = offendingSymbol match {\n      case token: CommonToken =>\n        val start = Origin(Some(line), Some(token.getCharPositionInLine))\n        val length = token.getStopIndex - token.getStartIndex + 1\n        val stop = Origin(Some(line), Some(token.getCharPositionInLine + length))\n        (start, stop)\n      case _ =>\n        val start = Origin(Some(line), Some(charPositionInLine))\n        (start, start)\n    }\n    throw new IcebergParseException(None, msg, start, stop)\n  }\n}\n\n/**\n * Copied from Apache Spark\n * A [[ParseException]] is an [[AnalysisException]] that is thrown during the parse process. It\n * contains fields and an extended error message that make reporting and diagnosing errors easier.\n */\nclass IcebergParseException(\n    val command: Option[String],\n    message: String,\n    val start: Origin,\n    val stop: Origin)\n    extends AnalysisException(message, start.line, start.startPosition) {\n\n  def this(message: String, ctx: ParserRuleContext) = {\n    this(\n      Option(IcebergParserUtils.command(ctx)),","sourceCodeStart":298,"sourceCodeEnd":334,"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#L298-L334","documentation":"This is the IcebergSqlExtensionsErrorStrategy's error handler, which builds and throws an IcebergParseException when the ANTLR-based extended grammar fails to recognize the input. It attaches the source line/position so the message displays the offending SQL fragment.","triggerScenarios":"Issuing SQL that matches neither standard Spark grammar nor Iceberg's extensions grammar — e.g. malformed ALTER TABLE ... WRITE DISTRIBUTED/ORDERED BY clauses, bad CALL arguments, or misspelled keywords.","commonSituations":"Hand-written SQL with typos, SQL generated by scripts with interpolation bugs, migrating statements across Iceberg versions where grammar changed, or forgetting that a feature requires a newer Iceberg release.","solutions":["Fix the SQL syntax at the reported line/position.","Confirm the statement is supported by your Iceberg version's grammar (check IcebergSqlExtensions.g4).","Test the statement against a minimal example to isolate the failing clause.","Upgrade Iceberg if the syntax is only available in newer releases."],"exampleFix":"// before\nspark.sql(\"ALTER TABLE t WRITE ORDERED B id\")\n// after\nspark.sql(\"ALTER TABLE t WRITE ORDERED BY id\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Scala\ntry { spark.sql(stmt) } catch {\n  case e: org.apache.iceberg.spark.sql.IcebergParseException =>\n    // e.message contains the SQL snippet and caret; surface it to the user\n    throw new IllegalArgumentException(s\"Bad Iceberg SQL: ${e.getMessage}\", e)\n}","preventionTips":["Keep SQL statements small and composed one clause at a time.","Validate SQL templates render non-empty clauses before execution.","Consult the IcebergSqlExtensions.g4 grammar for supported syntax.","Pin Iceberg versions; grammar changes between releases."],"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"}