FormattedSchemaDiff

class felis.diff.FormattedSchemaDiff(schema_old, schema_new, table_filter=[])

Bases: SchemaDiff

Compare two schemas using DeepDiff and emit structured JSON differences.

Parameters:
  • schema_old (Schema) – The old schema to compare, typically the original schema.

  • schema_new (Schema) – The new schema to compare, typically the modified schema.

  • table_filter (list[str], default: []) – A list of table names to filter on.

Notes

This class extends SchemaDiff to provide a more structured output of differences. It formats the differences into a list of dictionaries, each representing a change with details such as change type, path, and values involved.

Output dictionaries representing the changes are formatted as follows:

{
    "change_type": str,
    "id": str,
    "path": str,
    "old_value": Any (for value changes),
    "new_value": Any (for value changes),
    "value": Any (for additions/removals)
}

The changes can be printed to JSON using the print method.

Methods Summary

print([output_stream])

Print the differences between the two schemas as JSON.

to_change_list()

Convert differences to a structured format.

Methods Documentation

print(output_stream=None)

Print the differences between the two schemas as JSON.

Parameters:

output_stream (Optional[IO[str]], default: None) – The output stream for printing the differences.

Return type:

None

to_change_list()

Convert differences to a structured format.

Returns:

List of changes in their dictionary representation.

Return type:

list[dict[str, Any]]