@Test public void testParserVersionValidation() throws Exception { String supportedVersion = toJsonWithVersion( TableMetadata.newTableMetadata(TEST_SCHEMA, SPEC_5, TEST_LOCATION, ImmutableMap.of()), TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION); TableMetadata parsed = TableMetadataParser.fromJson( ops.io(), null, JsonUtil.mapper().readValue(supportedVersion, JsonNode.class)); Assert.assertNotNull("Should successfully read supported metadata version", parsed); String unsupportedVersion = toJsonWithVersion( TableMetadata.newTableMetadata(TEST_SCHEMA, SPEC_5, TEST_LOCATION, ImmutableMap.of()), TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION + 1); AssertHelpers.assertThrows("Should not read unsupported metadata", IllegalArgumentException.class, "Cannot read unsupported version", () -> TableMetadataParser.fromJson( ops.io(), null, JsonUtil.mapper().readValue(unsupportedVersion, JsonNode.class))); }
@Deprecated public static TableMetadata newTableMetadata(TableOperations ops, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) { return newTableMetadata(schema, spec, location, properties, DEFAULT_TABLE_FORMAT_VERSION); }
TableMetadata implements Serializable { @Deprecated public static TableMetadata newTableMetadata(TableOperations ops, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) { return newTableMetadata(schema, spec, location, properties, DEFAULT_TABLE_FORMAT_VERSION); } }
TableMetadata implements Serializable { @Deprecated public static TableMetadata newTableMetadata(TableOperations ops, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) { return newTableMetadata(schema, spec, location, properties, DEFAULT_TABLE_FORMAT_VERSION); } TableMetadata(InputFile file,
                int formatVersion,
                String uuid,
                String location,
                long lastSequenceNumber,
                long lastUpdatedMillis,
                int lastColumnId,
                Schema schema,
                int defaultSpecId,
                List<PartitionSpec> specs,
                Map<String, String> properties,
                long currentSnapshotId,
                List<Snapshot> snapshots,
                List<HistoryEntry> snapshotLog,
                List<MetadataLogEntry> previousFiles); }
TableMetadata implements Serializable { @Deprecated public static TableMetadata newTableMetadata(TableOperations ops, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) { return newTableMetadata(schema, spec, location, properties, DEFAULT_TABLE_FORMAT_VERSION); } TableMetadata(InputFile file,
                int formatVersion,
                String uuid,
                String location,
                long lastSequenceNumber,
                long lastUpdatedMillis,
                int lastColumnId,
                Schema schema,
                int defaultSpecId,
                List<PartitionSpec> specs,
                Map<String, String> properties,
                long currentSnapshotId,
                List<Snapshot> snapshots,
                List<HistoryEntry> snapshotLog,
                List<MetadataLogEntry> previousFiles); @Deprecated static TableMetadata newTableMetadata(TableOperations ops,
                                               Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); static TableMetadata newTableMetadata(Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); int formatVersion(); String metadataFileLocation(); String uuid(); long lastSequenceNumber(); long nextSequenceNumber(); long lastUpdatedMillis(); int lastColumnId(); Schema schema(); PartitionSpec spec(); PartitionSpec spec(int id); List<PartitionSpec> specs(); Map<Integer, PartitionSpec> specsById(); int defaultSpecId(); String location(); Map<String, String> properties(); String property(String property, String defaultValue); boolean propertyAsBoolean(String property, boolean defaultValue); int propertyAsInt(String property, int defaultValue); long propertyAsLong(String property, long defaultValue); Snapshot snapshot(long snapshotId); Snapshot currentSnapshot(); List<Snapshot> snapshots(); List<HistoryEntry> snapshotLog(); List<MetadataLogEntry> previousFiles(); TableMetadata withUUID(); TableMetadata updateSchema(Schema newSchema, int newLastColumnId); TableMetadata updatePartitionSpec(PartitionSpec newPartitionSpec); TableMetadata addStagedSnapshot(Snapshot snapshot); TableMetadata replaceCurrentSnapshot(Snapshot snapshot); TableMetadata removeSnapshotsIf(Predicate<Snapshot> removeIf); TableMetadata replaceProperties(Map<String, String> newProperties); TableMetadata removeSnapshotLogEntries(Set<Long> snapshotIds); TableMetadata buildReplacement(Schema updatedSchema, PartitionSpec updatedPartitionSpec,
                                        String newLocation, Map<String, String> updatedProperties); TableMetadata updateLocation(String newLocation); TableMetadata upgradeToFormatVersion(int newFormatVersion); }
TableMetadata implements Serializable { @Deprecated public static TableMetadata newTableMetadata(TableOperations ops, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) { return newTableMetadata(schema, spec, location, properties, DEFAULT_TABLE_FORMAT_VERSION); } TableMetadata(InputFile file,
                int formatVersion,
                String uuid,
                String location,
                long lastSequenceNumber,
                long lastUpdatedMillis,
                int lastColumnId,
                Schema schema,
                int defaultSpecId,
                List<PartitionSpec> specs,
                Map<String, String> properties,
                long currentSnapshotId,
                List<Snapshot> snapshots,
                List<HistoryEntry> snapshotLog,
                List<MetadataLogEntry> previousFiles); @Deprecated static TableMetadata newTableMetadata(TableOperations ops,
                                               Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); static TableMetadata newTableMetadata(Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); int formatVersion(); String metadataFileLocation(); String uuid(); long lastSequenceNumber(); long nextSequenceNumber(); long lastUpdatedMillis(); int lastColumnId(); Schema schema(); PartitionSpec spec(); PartitionSpec spec(int id); List<PartitionSpec> specs(); Map<Integer, PartitionSpec> specsById(); int defaultSpecId(); String location(); Map<String, String> properties(); String property(String property, String defaultValue); boolean propertyAsBoolean(String property, boolean defaultValue); int propertyAsInt(String property, int defaultValue); long propertyAsLong(String property, long defaultValue); Snapshot snapshot(long snapshotId); Snapshot currentSnapshot(); List<Snapshot> snapshots(); List<HistoryEntry> snapshotLog(); List<MetadataLogEntry> previousFiles(); TableMetadata withUUID(); TableMetadata updateSchema(Schema newSchema, int newLastColumnId); TableMetadata updatePartitionSpec(PartitionSpec newPartitionSpec); TableMetadata addStagedSnapshot(Snapshot snapshot); TableMetadata replaceCurrentSnapshot(Snapshot snapshot); TableMetadata removeSnapshotsIf(Predicate<Snapshot> removeIf); TableMetadata replaceProperties(Map<String, String> newProperties); TableMetadata removeSnapshotLogEntries(Set<Long> snapshotIds); TableMetadata buildReplacement(Schema updatedSchema, PartitionSpec updatedPartitionSpec,
                                        String newLocation, Map<String, String> updatedProperties); TableMetadata updateLocation(String newLocation); TableMetadata upgradeToFormatVersion(int newFormatVersion);  }