{"record":{"id":"621c22edc744a27a","repo":"apache/iceberg","slug":"cannot-parse","errorCode":null,"errorMessage":"Cannot parse : ","messagePattern":"Cannot parse : ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java","lineNumber":780,"sourceCode":"      SparkSession spark, String name, CatalogPlugin defaultCatalog) throws ParseException {\n    ParserInterface parser = spark.sessionState().sqlParser();\n    Seq<String> multiPartIdentifier = parser.parseMultipartIdentifier(name).toIndexedSeq();\n    List<String> javaMultiPartIdentifier = JavaConverters.seqAsJavaList(multiPartIdentifier);\n    return catalogAndIdentifier(spark, javaMultiPartIdentifier, defaultCatalog);\n  }\n\n  public static CatalogAndIdentifier catalogAndIdentifier(\n      String description, SparkSession spark, String name) {\n    return catalogAndIdentifier(\n        description, spark, name, spark.sessionState().catalogManager().currentCatalog());\n  }\n\n  public static CatalogAndIdentifier catalogAndIdentifier(\n      String description, SparkSession spark, String name, CatalogPlugin defaultCatalog) {\n    try {\n      return catalogAndIdentifier(spark, name, defaultCatalog);\n    } catch (ParseException e) {\n      throw new IllegalArgumentException(\"Cannot parse \" + description + \": \" + name, e);\n    }\n  }\n\n  public static CatalogAndIdentifier catalogAndIdentifier(\n      SparkSession spark, List<String> nameParts) {\n    return catalogAndIdentifier(\n        spark, nameParts, spark.sessionState().catalogManager().currentCatalog());\n  }\n\n  /**\n   * A modified version of Spark's LookupCatalog.CatalogAndIdentifier.unapply Attempts to find the\n   * catalog and identifier a multipart identifier represents\n   *\n   * @param spark Spark session to use for resolution\n   * @param nameParts Multipart identifier representing a table\n   * @param defaultCatalog Catalog to use if none is specified\n   * @return The CatalogPlugin and Identifier for the table\n   */","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java#L762-L798","documentation":"Spark3Util.catalogAndIdentifier(description, spark, name, defaultCatalog) parses an identifier string into a (catalog, namespace, table) triple using Spark's parser. If the name cannot be parsed as a valid multi-part identifier it throws IllegalArgumentException 'Cannot parse <description>: <name>', wrapping the original ParseException.","triggerScenarios":"Passing a malformed table/identifier string — unbalanced quotes/backticks, empty name, illegal characters — to catalogAndIdentifier or APIs that use it (e.g. loadTable helpers, ALTER/DESCRIBE resolution).","commonSituations":"Identifiers built by string concatenation with missing backticks around special characters; whitespace or newline typos; programmatic names containing dots not escaped.","solutions":["Fix the identifier string: backtick-quote each part, e.g. `cat`.`ns`.`tbl`, and remove stray whitespace/quotes","Pass nameParts as a List<String> via catalogAndIdentifier(spark, List<String>) instead of a raw string to skip parsing","Validate the name with a quick parse or regex before calling","Catch IllegalArgumentException and surface a clearer message describing expected format"],"exampleFix":"// before\ncatalogAndIdentifier(spark, \"my-catalog:db.table\") // colon not parseable\n// after\ncatalogAndIdentifier(spark, ImmutableList.of(\"my-catalog\", \"db\", \"table\"))","handlingStrategy":"try-catch","validationCode":"// Quick pre-check: identifier must be non-empty and parse into dot-separated parts\nif (name == null || name.isBlank()) {\n  throw new IllegalArgumentException(\"Identifier must be non-empty\");\n}","typeGuard":"boolean isParsableIdentifier(String name) {\n  return name != null && !name.isBlank() && !name.startsWith(\"`\") && name.chars().noneMatch(c -> c == ';');\n}","tryCatchPattern":"try {\n  CatalogAndIdentifier id = Spark3Util.catalogAndIdentifier(spark, name, defaultCatalog);\n} catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Malformed table identifier, expected [catalog.]namespace.table: \" + name, e);\n}","preventionTips":["Backtick-quote identifier parts containing special characters","Prefer the List<String> nameParts overload for programmatic identifiers","Trim whitespace and avoid concatenating catalog/namespace/table with ad-hoc separators"],"tags":["spark","identifier-parsing","argument"],"backgroundTag":"invalid-identifier-format","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"}