{"record":{"id":"66039c149bb2db91","repo":"apache/iceberg","slug":"tablenotpartitionedexception","errorCode":null,"errorMessage":"TableNotPartitionedException","messagePattern":"TableNotPartitionedException","errorType":"exception","errorClass":"TableNotPartitionedException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java","lineNumber":818,"sourceCode":"  }\n\n  @Override\n  public void alterPartitionColumnStatistics(\n      ObjectPath tablePath,\n      CatalogPartitionSpec partitionSpec,\n      CatalogColumnStatistics columnStatistics,\n      boolean ignoreIfNotExists)\n      throws CatalogException {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public List<CatalogPartitionSpec> listPartitions(ObjectPath tablePath)\n      throws TableNotExistException, TableNotPartitionedException, CatalogException {\n    Table table = loadIcebergTable(tablePath);\n\n    if (table.spec().isUnpartitioned()) {\n      throw new TableNotPartitionedException(icebergCatalog.name(), tablePath);\n    }\n\n    Set<CatalogPartitionSpec> set = Sets.newHashSet();\n    try (CloseableIterable<FileScanTask> tasks = table.newScan().planFiles()) {\n      for (DataFile dataFile : CloseableIterable.transform(tasks, FileScanTask::file)) {\n        Map<String, String> map = Maps.newHashMap();\n        StructLike structLike = dataFile.partition();\n        PartitionSpec spec = table.specs().get(dataFile.specId());\n        for (int i = 0; i < structLike.size(); i++) {\n          map.put(spec.fields().get(i).name(), String.valueOf(structLike.get(i, Object.class)));\n        }\n        set.add(new CatalogPartitionSpec(map));\n      }\n    } catch (IOException e) {\n      throw new CatalogException(\n          String.format(\"Failed to list partitions of table %s\", tablePath), e);\n    }\n","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L800-L836","documentation":"listPartitions throws TableNotPartitionedException when the underlying Iceberg table is unpartitioned. Iceberg has no partition specs to enumerate for such tables, so Flink's catalog contract requires signaling that the table is not partitioned.","triggerScenarios":"Calling catalog.listPartitions(tablePath) (or Flink SQL operations that enumerate partitions) on an Iceberg table created with PartitionSpec.unpartitioned().","commonSituations":"Pointing Flink SQL at a plain Iceberg table and running partition-aware queries; generic tooling that lists partitions for any table; accidental use of an unpartitioned table where partitioned data was expected.","solutions":["Check table.spec().isUnpartitioned() before calling listPartitions and handle unpartitioned tables separately","If partitions are expected, recreate/rewrite the table with a partition spec via Iceberg APIs","Catch TableNotPartitionedException and fall back to whole-table scanning"],"exampleFix":"// before\nList<CatalogPartitionSpec> parts = catalog.listPartitions(tablePath);\n\n// after\nif (!((FlinkCatalog) catalog).loadIcebergTable(tablePath).spec().isUnpartitioned()) {\n  List<CatalogPartitionSpec> parts = catalog.listPartitions(tablePath);\n}","handlingStrategy":"validation","validationCode":"Table t = ((FlinkCatalog) catalog).loadIcebergTable(tablePath);\nif (t.spec().isUnpartitioned()) { /* handle unpartitioned case */ } else { catalog.listPartitions(tablePath); }","typeGuard":null,"tryCatchPattern":"try { catalog.listPartitions(tablePath); } catch (TableNotPartitionedException e) { /* scan whole table instead */ }","preventionTips":["Check spec().isUnpartitioned() before partition enumeration","Make table partitioning an explicit design decision","Handle unpartitioned tables in generic tooling"],"tags":["flink","partitioned-table","catalog","unsupported-operation"],"backgroundTag":"invalid-state-transition","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"}