{"record":{"id":"0e8dcf8c30cfc4f9","repo":"apache/iceberg","slug":"unable-to-parse-the-table-identifier-s","errorCode":null,"errorMessage":"Unable to parse the table identifier: %s","messagePattern":"Unable to parse the table identifier: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java","lineNumber":236,"sourceCode":"          e, \"Unknown table: %s. Table not found in catalog.\", tableIdent);\n    }\n  }\n\n  /**\n   * Returns partitions that match the specified 'predicate'.\n   *\n   * @param spark a Spark session\n   * @param table a table name and (optional) database\n   * @param predicate a predicate on partition columns\n   * @return matching table's partitions\n   */\n  public static List<SparkPartition> getPartitionsByFilter(\n      SparkSession spark, String table, String predicate) {\n    TableIdentifier tableIdent;\n    try {\n      tableIdent = spark.sessionState().sqlParser().parseTableIdentifier(table);\n    } catch (ParseException e) {\n      throw SparkExceptionUtil.toUncheckedException(\n          e, \"Unable to parse the table identifier: %s\", table);\n    }\n\n    Expression unresolvedPredicateExpr;\n    try {\n      unresolvedPredicateExpr = spark.sessionState().sqlParser().parseExpression(predicate);\n    } catch (ParseException e) {\n      throw SparkExceptionUtil.toUncheckedException(\n          e, \"Unable to parse the predicate expression: %s\", predicate);\n    }\n\n    Expression resolvedPredicateExpr = resolveAttrs(spark, table, unresolvedPredicateExpr);\n    return getPartitionsByFilter(spark, tableIdent, resolvedPredicateExpr);\n  }\n\n  /**\n   * Returns partitions that match the specified 'predicate'.\n   *","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java#L218-L254","documentation":"Thrown when Spark's SQL parser fails to parse the given string as a table identifier in getPartitionsByFilter(spark, table, predicate). SparkTableUtil wraps the ParseException into an unchecked exception naming the offending input.","triggerScenarios":"Calling SparkTableUtil.getPartitionsByFilter(spark, table, predicate) where `table` is not a valid identifier — empty string, extra tokens, unquoted special characters (dots, hyphens, spaces), or accidental predicate text pasted into the table argument.","commonSituations":"Programmatically assembled identifiers containing unescaped dots; forgetting backticks around names with special chars; passing a fully qualified v2 catalog identifier the session parser rejects; swapping the table and predicate arguments by mistake.","solutions":["Quote special characters with backticks: `my-catalog`.`db`.`table-name`.","Validate the identifier parses before use: spark.sessionState().sqlParser().parseTableIdentifier(table) in a dry run.","Check argument order — the table string must come before the predicate string.","Strip whitespace/invalid tokens when the identifier is built dynamically."],"exampleFix":"// before\nSparkTableUtil.getPartitionsByFilter(spark, \"db.my-table ts > 100\", \"\");\n// after\nSparkTableUtil.getPartitionsByFilter(spark, \"db.`my-table`\", \"ts > 100\");","handlingStrategy":"validation","validationCode":"try {\n  spark.sessionState().sqlParser().parseTableIdentifier(table);\n} catch (ParseException e) {\n  throw new IllegalArgumentException(\"Invalid table identifier: \" + table, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  SparkTableUtil.getPartitionsByFilter(spark, table, predicate);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to parse the table identifier\")) {\n    throw new IllegalArgumentException(\"Bad table identifier: \" + table, e);\n  }\n  throw e;\n}","preventionTips":["Backtick-quote identifier parts containing dots or hyphens","Dry-run parseTableIdentifier on dynamic identifiers","Double-check argument order (table before predicate)"],"tags":["spark","sql-parser","identifier-parsing"],"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"}