{"record":{"id":"f8ae16399a5871cc","repo":"apache/iceberg","slug":"cannot-pass-path-based-identifier-to-s-method-s-f8ae16","errorCode":null,"errorMessage":"Cannot pass path based identifier to %s method. %s is a path.","messagePattern":"Cannot pass path based identifier to (.+?) method\\. (.+?) is a path\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":885,"sourceCode":"\n    if (!propertyChanges.isEmpty()) {\n      Spark3Util.applyPropertyChanges(transaction.updateProperties(), propertyChanges).commit();\n    }\n\n    if (!schemaChanges.isEmpty()) {\n      Spark3Util.applySchemaChanges(transaction.updateSchema(), schemaChanges).commit();\n    }\n\n    transaction.commitTransaction();\n  }\n\n  private static boolean isPathIdentifier(Identifier ident) {\n    return ident instanceof PathIdentifier;\n  }\n\n  private static void checkNotPathIdentifier(Identifier identifier, String method) {\n    if (identifier instanceof PathIdentifier) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot pass path based identifier to %s method. %s is a path.\", method, identifier));\n    }\n  }\n\n  private Table load(Identifier ident) {\n    if (isPathIdentifier(ident)) {\n      return loadFromPathIdentifier((PathIdentifier) ident);\n    }\n\n    try {\n      org.apache.iceberg.Table table = icebergCatalog.loadTable(buildIdentifier(ident));\n      return new SparkTable(table, !cacheEnabled);\n\n    } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {\n      if (ident.namespace().length == 0) {\n        throw e;\n      }","sourceCodeStart":867,"sourceCodeEnd":903,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L867-L903","documentation":"checkNotPathIdentifier throws IllegalArgumentException when a PathIdentifier (an identifier parsed from a file/table path, e.g. 'parquet./path/to/data') is passed to an identifier-only catalog method such as createTable, dropTable, renameTable, or view operations. Path-based identifiers are only valid for load-style operations; mutation/DDL methods require namespace-based identifiers.","triggerScenarios":"Calling SparkCatalog.createTable/dropTable/renameTable/alterTable (or view DDL) with an Identifier built from a path string instead of a (namespace, name) pair; passing 'file:///tmp/t' where a table name is expected.","commonSituations":"Users treating a loaded path-table like a catalog table and then trying DDL on it; Spark SQL statements that resolve to path identifiers via 'parquet.`/path`' syntax; scripts mixing path loads with catalog operations.","solutions":["Register the data as a named table in the catalog and use its namespace.name identifier for DDL.","Use the path-qualified syntax only for read operations (SELECT ... FROM parquet.`/path`).","For tables created from paths, ensure CREATE TABLE ... USING iceberg LOCATION is done through the catalog so an identifier exists."],"exampleFix":"// before\nspark.catalog.dropTable(\"parquet.`/tmp/data/t`\") // path identifier: throws\n// after\nspark.sql(\"DROP TABLE my_catalog.db.t\") // named catalog table","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean isPathIdentifier(org.apache.spark.sql.connector.catalog.Identifier ident) {\n  return ident instanceof org.apache.iceberg.spark.PathIdentifier;\n}\n// guard: if (isPathIdentifier(ident)) resolve a catalog (namespace, name) identifier first","tryCatchPattern":"try {\n  sparkCatalog.dropTable(ident);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"path based identifier\")) { /* convert path table to named table first */ }\n  throw e;\n}","preventionTips":["Never pass 'parquet./path' style identifiers to DDL methods.","Register path data as catalog tables before mutating them.","Route path-based reads through SELECT and catalog writes through named tables."],"tags":["spark","identifier","path","invalid-argument"],"backgroundTag":"invalid-argument-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"}