{"record":{"id":"7baec25d9411034e","repo":"apache/iceberg","slug":"no-such-table-s","errorCode":null,"errorMessage":"No such table: %s","messagePattern":"No such table: (.+?)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java","lineNumber":368,"sourceCode":"      Map<String, String> properties = propertiesBuilder.build();\n      TableMetadata metadata = tableMetadata(schema, spec, null, properties, location);\n      return Transactions.createTableTransaction(location, ops, metadata);\n    }\n\n    @Override\n    public Transaction replaceTransaction() {\n      return newReplaceTableTransaction(false);\n    }\n\n    @Override\n    public Transaction createOrReplaceTransaction() {\n      return newReplaceTableTransaction(true);\n    }\n\n    private Transaction newReplaceTableTransaction(boolean orCreate) {\n      TableOperations ops = newTableOps(location);\n      if (!orCreate && ops.current() == null) {\n        throw new NoSuchTableException(\"No such table: %s\", location);\n      }\n\n      Map<String, String> properties = propertiesBuilder.build();\n      TableMetadata metadata;\n      if (ops.current() != null) {\n        metadata = ops.current().buildReplacement(schema, spec, sortOrder, location, properties);\n      } else {\n        metadata = tableMetadata(schema, spec, sortOrder, properties, location);\n      }\n\n      if (orCreate) {\n        return Transactions.createOrReplaceTableTransaction(location, ops, metadata);\n      } else {\n        return Transactions.replaceTableTransaction(location, ops, metadata);\n      }\n    }\n  }\n","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java#L350-L386","documentation":"HadoopTables throws NoSuchTableException from replaceTransaction when the table does not exist at the location and orCreate is false. A replacement requires an existing table to replace. Callers wanting create-or-replace semantics should use createOrReplaceTransaction instead.","triggerScenarios":"Calling replaceTransaction(location, ...) when no table metadata exists at the location. Common when the table was deleted, the location is wrong, or the table was never created.","commonSituations":"Typo in table location; table dropped by another job between check and replace; assuming replace implies create (it does not).","solutions":["Verify the table exists with tables.exists(location) before replacing","Use createOrReplaceTransaction(...) if create-if-missing semantics are wanted","Correct the table location string","Create the table first if it genuinely does not exist"],"exampleFix":"// before\nTransaction tx = tables.replaceTransaction(schema, spec, props, location);\n// after\nTransaction tx = tables.createOrReplaceTransaction(schema, spec, props, location);","handlingStrategy":"validation","validationCode":"if (!tables.exists(location)) { /* create instead of replace, or fail early */ }","typeGuard":null,"tryCatchPattern":"try { Transaction tx = tables.replaceTransaction(schema, spec, props, location); } catch (NoSuchTableException e) { Transaction tx = tables.createTransaction(schema, spec, props, location); }","preventionTips":["Use createOrReplaceTransaction when create-if-missing is desired","Verify location correctness before replace","Be aware replace does not imply create","Coordinate with jobs that may drop the table concurrently"],"tags":["hadoop","no-such-table","catalog"],"backgroundTag":"resource-not-found","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"}