{"record":{"id":"88d9e96ec1ad6588","repo":"apache/beam","slug":"table-schema-is-null","errorCode":null,"errorMessage":"Table schema is null.","messagePattern":"Table schema is null\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/delta/src/main/java/org/apache/beam/sdk/io/delta/DeltaIO.java","lineNumber":164,"sourceCode":"          conf.set(entry.getKey(), entry.getValue());\n        }\n      }\n      Engine engine = DefaultEngine.create(conf);\n      Table table = Table.forPath(engine, path);\n      Snapshot snapshot;\n      Long versionVal = getVersion();\n      String timestampVal = getTimestamp();\n      if (versionVal != null) {\n        snapshot = table.getSnapshotAsOfVersion(engine, versionVal);\n      } else if (timestampVal != null) {\n        long timestampMillis = java.time.Instant.parse(timestampVal).toEpochMilli();\n        snapshot = table.getSnapshotAsOfTimestamp(engine, timestampMillis);\n      } else {\n        snapshot = table.getLatestSnapshot(engine);\n      }\n      StructType deltaSchema = snapshot.getSchema();\n      if (deltaSchema == null) {\n        throw new IllegalStateException(\"Table schema is null.\");\n      }\n      Schema beamSchema = convertToBeamSchema(deltaSchema);\n\n      return input\n          .apply(\"Create Path\", Create.of(path))\n          .apply(\n              \"Plan Files\",\n              ParDo.of(new CreateReadTasksDoFn(hadoopConfig, getVersion(), getTimestamp())))\n          .apply(\"Read Logical Data\", ParDo.of(new DeltaSourceDoFn(hadoopConfig)))\n          .setRowSchema(beamSchema);\n    }\n\n    static Schema convertToBeamSchema(StructType deltaSchema) {\n      Schema.Builder builder = Schema.builder();\n      for (StructField field : deltaSchema.fields()) {\n        builder.addField(\n            Schema.Field.of(field.getName(), convertToBeamFieldType(field.getDataType()))\n                .withNullable(field.isNullable()));","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/delta/src/main/java/org/apache/beam/sdk/io/delta/DeltaIO.java#L146-L182","documentation":"After resolving a snapshot via version or timestamp, expand() fetches its schema via snapshot.getSchema(). Delta Kernel should always return a schema; a null means the connector's internal invariant was violated, so it throws IllegalStateException instead of producing a Beam schema.","triggerScenarios":"snapshot.getSchema() returning null — unexpected Delta Kernel behavior, a corrupted/missing Delta log that yields a degenerate snapshot, or a connector/Kernel version mismatch.","commonSituations":"Pointing at a directory with a partial or corrupt _delta_log; using a Delta Kernel version incompatible with the table protocol/writer features; a table where schema was never properly committed.","solutions":["Verify the table is a valid Delta table (complete _delta_log with valid schema in the latest commit).","Align the Delta Kernel dependency version with the table's protocol/minReaderVersion — upgrade the kernel if the table uses newer features.","Re-check the resolved version/timestamp; try reading the latest snapshot to see if only a historical version is corrupt.","If the table is corrupt, restore from a recent commit or rewrite the table."],"exampleFix":"// before\nsnapshot = table.getSnapshotAsOfTimestamp(engine, ts); // corrupt/partial _delta_log\n// after\n// validate the table first (e.g. with delta-spark): DESCRIBE HISTORY / VALIDATE, or read latest snapshot\nsnapshot = table.getLatestSnapshot(engine);\nStructType schema = snapshot.getSchema();\nif (schema == null) throw new IllegalStateException(\"table at \" + path + \" has no valid schema\");","handlingStrategy":"try-catch","validationCode":"// validate the table is readable before launching Beam\n// run: DESCRIBE HISTORY <path> (delta-spark) or read latest snapshot with Kernel to confirm schema","typeGuard":null,"tryCatchPattern":"try { pipeline.run(); } catch (IllegalStateException e) { if (e.getMessage().equals(\"Table schema is null.\")) { validateTableAndKernelVersion(); } else { throw e; } }","preventionTips":["Point reads at directories with a complete, valid _delta_log.","Keep the Delta Kernel dependency compatible with the table's protocol version.","Smoke-test the table with the latest-snapshot read before time-travel reads."],"tags":["java","delta-lake","null-check","internal-invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}