django-data-shape 0.18.0__tar.gz → 0.18.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/CHANGELOG.md +24 -1
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/PKG-INFO +1 -1
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/projection.py +26 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/scaled_shape.py +12 -3
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/version.py +1 -1
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/projections.md +6 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/pyproject.toml +1 -1
- django_data_shape-0.18.1/tests/test_scaled_projection_ceiling.py +103 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/CODEOWNERS +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/SECURITY.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/dependabot.yml +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/workflows/release.yml +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/workflows/tests.yml +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/workflows/upstream-drift.yml +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.gitignore +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.pre-commit-config.yaml +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/CLAUDE.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/LICENSE +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/Makefile +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/README.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/apply_statistics_targets.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/build.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/build_result.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/canonical.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/check_constraints.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/check_invariants.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/children_per_parent.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/clone_database.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivation_queried_database.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/after.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/aligned.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/copied.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/derivation.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/derived.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/given.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/offset.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/per_parent.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/product.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/scope.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/ascending.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/bounded.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/categorical.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/constant.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/distinct.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/distribution.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/sequential.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/skew.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/uniform.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/zipf.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/drop_database.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fan_out.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fan_out_plan.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fan_out_sizes.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/scale_fixture.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/shape_fixture.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/skip_unless_postgres.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/generate_rows.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/infer_key_strategy.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/invalid_shape.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/invariant.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/invariant_violated.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/disjoint.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/key_function.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/key_strategy.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/md5_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/sequential_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/sql_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/uuid_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/order_derivations.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/order_tables.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/paired.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/paired_plan.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/py.typed +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/refuse_queries.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/require_clone_strategy.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/require_postgres.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/resolve_fan_out.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/resolve_paired.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/scale_protocol.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/scaled_world.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape_digest.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape_from_factory.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape_not_empty.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/table.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/table_result.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/template_database.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/unhashable_shape.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/unsupported_backend.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/utils.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/world_changed.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/derivations.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/index.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/invariants.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/keys.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/pytest.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/reference.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/relations.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/statistics.md +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/mkdocs.yml +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/scripts/check-changelog +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/scripts/release-publish.sh +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/conftest.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/conftest_settings.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_after.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_after_units.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_aligned.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_canonical_arithmetic.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_derived.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_given.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_per_parent.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_constant.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_sequential.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_skew.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_uniform.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_zipf.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_key_function.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_md5_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_sequential_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_uuid_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/scale_protocol_consumers.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/scale_protocol_impostors.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_apply_statistics_targets.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_derivations.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_graph.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_invariants.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_keys.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_m2m.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_portable.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_projection.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_check_constraints.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_children_per_parent.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_documentation.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_fan_out.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_fan_out_sizes.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_fixtures.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_generate_rows.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_infer_key_strategy.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_invariant.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_order_derivations.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_order_tables.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_paired.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_paired_plan.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_projection.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_projection_ceiling.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_reference_documents_the_public_surface.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_refuse_queries.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_require_clone_strategy.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_require_postgres.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_resolve_fan_out.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_resolve_paired.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scale_protocol.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_shape.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_world.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_world_over_a_session_world.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_world_restores_sequences.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_shape.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_shape_digest.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_shape_from_factory.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_table.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_template_database.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_utils.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_version.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/testapp/__init__.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/testapp/models.py +0 -0
- {django_data_shape-0.18.0 → django_data_shape-0.18.1}/uv.lock +0 -0
|
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.18.1] — 2026-09-05
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **`scaled_shape` now multiplies a projection's `max_rows` by the factor.**
|
|
15
|
+
It passed a `Projection` through untouched, which is right for its *size* --
|
|
16
|
+
that grows because the tables it reads did -- and wrong for a declared
|
|
17
|
+
ceiling, which is a number in the same units and did not move. A ceiling sized
|
|
18
|
+
for the world as written therefore refused every growth assertion, because
|
|
19
|
+
those build the same declaration at a larger factor.
|
|
20
|
+
|
|
21
|
+
The consumer that asked for `max_rows` in 0.18.0 hit this on the first run:
|
|
22
|
+
10,000 declared against a world of 3,188 rows, and 29,078 at factor 10.
|
|
23
|
+
|
|
24
|
+
Multiplying is the arithmetic rather than an approximation of one, and the
|
|
25
|
+
reason is the same one that makes the size need no factor: every table scales,
|
|
26
|
+
parents included, so a parent has the same number of children at every factor
|
|
27
|
+
and the projection is a sum over `factor` times as many parents of an
|
|
28
|
+
unchanged per-parent product.
|
|
29
|
+
|
|
30
|
+
A declaration with no ceiling is still passed through by identity.
|
|
31
|
+
|
|
10
32
|
## [0.18.0] — 2026-09-05
|
|
11
33
|
|
|
12
34
|
### Added
|
|
@@ -1173,7 +1195,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1173
1195
|
into `COPY FROM STDIN`, which psycopg 2 cannot do without materialising them
|
|
1174
1196
|
first.
|
|
1175
1197
|
|
|
1176
|
-
[Unreleased]: https://github.com/Artui/django-data-shape/compare/v0.18.
|
|
1198
|
+
[Unreleased]: https://github.com/Artui/django-data-shape/compare/v0.18.1...HEAD
|
|
1199
|
+
[0.18.1]: https://github.com/Artui/django-data-shape/compare/v0.18.0...v0.18.1
|
|
1177
1200
|
[0.18.0]: https://github.com/Artui/django-data-shape/compare/v0.17.1...v0.18.0
|
|
1178
1201
|
[0.17.1]: https://github.com/Artui/django-data-shape/compare/v0.17.0...v0.17.1
|
|
1179
1202
|
[0.17.0]: https://github.com/Artui/django-data-shape/compare/v0.16.0...v0.17.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-data-shape
|
|
3
|
-
Version: 0.18.
|
|
3
|
+
Version: 0.18.1
|
|
4
4
|
Summary: A realistically shaped test database from Django models: declare cardinality, skew and fan-out, load by COPY, and make the query planner believe it.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Artui/django-data-shape
|
|
6
6
|
Project-URL: Repository, https://github.com/Artui/django-data-shape
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from collections import Counter
|
|
6
6
|
from collections.abc import Mapping, Sequence
|
|
7
|
+
from copy import copy
|
|
7
8
|
from types import MappingProxyType
|
|
8
9
|
from typing import Any, cast
|
|
9
10
|
|
|
@@ -302,6 +303,31 @@ class Projection:
|
|
|
302
303
|
defaults = tuple(value for _column, value in self._literals)
|
|
303
304
|
return f"{into} {self._select(quote, seed)}", defaults
|
|
304
305
|
|
|
306
|
+
def scaled(self, factor: int) -> Projection:
|
|
307
|
+
"""This declaration at another size, which for a projection is its ceiling.
|
|
308
|
+
|
|
309
|
+
A projection has no row count to multiply -- its size is
|
|
310
|
+
``count(per JOIN copying)``, so scaling the tables it reads scales it
|
|
311
|
+
without anything being said. ``max_rows`` is different: it is a declared
|
|
312
|
+
number in the same units as that size, and a ceiling that does not move
|
|
313
|
+
with the factor fires on the first growth assertion.
|
|
314
|
+
|
|
315
|
+
**Multiplying it by the factor is the right arithmetic rather than an
|
|
316
|
+
approximation of one**, and for the same reason the count needs no
|
|
317
|
+
factor. ``scaled_shape`` scales *every* table, parents included, so a
|
|
318
|
+
parent has the same number of children at every factor; the projection
|
|
319
|
+
is then a sum over ``factor`` times as many parents of an unchanged
|
|
320
|
+
per-parent product, which is ``factor`` times the original.
|
|
321
|
+
|
|
322
|
+
Returns ``self`` when there is no ceiling, so a declaration that did not
|
|
323
|
+
ask for one keeps the identity it always had here.
|
|
324
|
+
"""
|
|
325
|
+
if self._max_rows is None:
|
|
326
|
+
return self
|
|
327
|
+
scaled = copy(self)
|
|
328
|
+
scaled._max_rows = self._max_rows * factor
|
|
329
|
+
return scaled
|
|
330
|
+
|
|
305
331
|
def count_statement(self, connection: Any) -> tuple[str, tuple[object, ...]]:
|
|
306
332
|
"""How many rows the insert would write, without writing them.
|
|
307
333
|
|
|
@@ -71,14 +71,23 @@ def scaled_shape(shape: Shape, factor: int) -> Shape:
|
|
|
71
71
|
because a message about a row count the caller never wrote is a message that
|
|
72
72
|
knows more than it says.
|
|
73
73
|
|
|
74
|
-
**A :class:`~django_data_shape.projection.Projection`
|
|
75
|
-
|
|
74
|
+
**A :class:`~django_data_shape.projection.Projection` needs no factor for
|
|
75
|
+
its size, and one for its ceiling.** It has no declared row count to
|
|
76
76
|
multiply: its size is ``count(per JOIN copying)``, so scaling the tables it
|
|
77
77
|
reads scales it by exactly the same amount without anything being said.
|
|
78
78
|
That is the determined-not-distributed property paying for itself -- a
|
|
79
79
|
mirroring vocabulary with a row count in it would have needed a rule here,
|
|
80
80
|
and would have had to pick between scaling the count and scaling the thing
|
|
81
81
|
the count was derived from.
|
|
82
|
+
|
|
83
|
+
``max_rows`` **is** multiplied, and the same reasoning is why. A ceiling is
|
|
84
|
+
a declared number in the same units as that size, so one that stayed put
|
|
85
|
+
would fire on the first growth assertion -- which is exactly what a consumer
|
|
86
|
+
hit within a run of asking for the feature. Because every table scales,
|
|
87
|
+
parents included, a parent has the same number of children at every factor
|
|
88
|
+
and the projection is a sum over ``factor`` times as many parents of an
|
|
89
|
+
unchanged per-parent product: linear, so multiplying the ceiling is the
|
|
90
|
+
arithmetic rather than an approximation of it.
|
|
82
91
|
"""
|
|
83
92
|
# A whole number, checked rather than rounded. Rounding would let each table
|
|
84
93
|
# decide its own size at a fractional factor, so two tables in one shape
|
|
@@ -94,7 +103,7 @@ def scaled_shape(shape: Shape, factor: int) -> Shape:
|
|
|
94
103
|
|
|
95
104
|
try:
|
|
96
105
|
tables = tuple(
|
|
97
|
-
table
|
|
106
|
+
table.scaled(factor)
|
|
98
107
|
if isinstance(table, Projection)
|
|
99
108
|
# ``fields`` rather than keyword arguments, because a model may have
|
|
100
109
|
# a column named ``rows`` or ``model``. Everything else is forwarded
|
|
@@ -117,6 +117,12 @@ count by four grows this by sixteen. Either the ceiling is too low, or one of
|
|
|
117
117
|
those counts moved further than it looked.
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
`scaled_shape` multiplies the ceiling by the factor, for the same reason the
|
|
121
|
+
size needs no factor at all: every table scales, parents included, so a parent
|
|
122
|
+
has the same number of children at every factor and the projection is a sum over
|
|
123
|
+
`factor` times as many parents of an unchanged per-parent product. A ceiling
|
|
124
|
+
that stayed put would fire on the first growth assertion.
|
|
125
|
+
|
|
120
126
|
A declaration that does not set one is not charged for the answer -- no count is
|
|
121
127
|
taken. **There is no default ceiling and there will not be one**: how many rows
|
|
122
128
|
is too many is a judgement about size, which this package does not make on your
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""A projection's ceiling has to move with the factor, or it fires at scale.
|
|
2
|
+
|
|
3
|
+
`scaled_shape` multiplies every table's row count and passed a `Projection`
|
|
4
|
+
through untouched, which is right for its *count* -- that grows because the
|
|
5
|
+
tables it reads did -- and wrong for a declared ceiling, which is a number in the
|
|
6
|
+
same units and did not move.
|
|
7
|
+
|
|
8
|
+
The consumer that asked for `max_rows` hit this on the first run: a ceiling
|
|
9
|
+
sized for the world as written refused every growth assertion, because those
|
|
10
|
+
build the same declaration at a larger factor.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import pytest
|
|
16
|
+
from django.db import connection
|
|
17
|
+
|
|
18
|
+
from django_data_shape import (
|
|
19
|
+
Constant,
|
|
20
|
+
FanOut,
|
|
21
|
+
InvalidShape,
|
|
22
|
+
Projection,
|
|
23
|
+
Sequential,
|
|
24
|
+
Shape,
|
|
25
|
+
Skew,
|
|
26
|
+
Table,
|
|
27
|
+
Uniform,
|
|
28
|
+
Zipf,
|
|
29
|
+
scaled_shape,
|
|
30
|
+
scaled_world,
|
|
31
|
+
)
|
|
32
|
+
from tests.testapp.models import Event, EventSession, Template, TemplateSession
|
|
33
|
+
|
|
34
|
+
pytestmark = pytest.mark.django_db
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _shape(*, max_rows: int | None) -> Shape:
|
|
38
|
+
return Shape(
|
|
39
|
+
Projection(EventSession, per=Event, copying=TemplateSession, max_rows=max_rows),
|
|
40
|
+
Table(Template, rows=4, name=Constant("t")),
|
|
41
|
+
Table(
|
|
42
|
+
TemplateSession,
|
|
43
|
+
rows=40,
|
|
44
|
+
template=FanOut(Zipf(1.1)),
|
|
45
|
+
title=Skew({"morning": 0.5, "evening": 0.5}),
|
|
46
|
+
minutes=Sequential(15, 1),
|
|
47
|
+
),
|
|
48
|
+
Table(Event, rows=20, template=FanOut(Uniform(1, 4)), name=Constant("e")),
|
|
49
|
+
seed=3,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_the_ceiling_is_multiplied_by_the_factor() -> None:
|
|
54
|
+
scaled = scaled_shape(_shape(max_rows=1_000), 10)
|
|
55
|
+
|
|
56
|
+
projection = next(t for t in scaled.tables if isinstance(t, Projection))
|
|
57
|
+
assert projection.max_rows == 10_000
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_a_declaration_with_no_ceiling_is_still_passed_through_untouched() -> None:
|
|
61
|
+
shape = _shape(max_rows=None)
|
|
62
|
+
original = next(t for t in shape.tables if isinstance(t, Projection))
|
|
63
|
+
|
|
64
|
+
scaled = scaled_shape(shape, 10)
|
|
65
|
+
|
|
66
|
+
assert next(t for t in scaled.tables if isinstance(t, Projection)) is original
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_the_original_declaration_is_not_mutated() -> None:
|
|
70
|
+
"""A shape is inert data, and scaling it must not edit the one it came from."""
|
|
71
|
+
shape = _shape(max_rows=1_000)
|
|
72
|
+
|
|
73
|
+
scaled_shape(shape, 10)
|
|
74
|
+
|
|
75
|
+
assert next(t for t in shape.tables if isinstance(t, Projection)).max_rows == 1_000
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_a_scaled_world_builds_under_a_ceiling_sized_for_factor_one() -> None:
|
|
79
|
+
"""The consumer's case, end to end.
|
|
80
|
+
|
|
81
|
+
Every table scales by the same factor, so a parent has the same number of
|
|
82
|
+
children at every factor and the projection grows linearly -- which is why
|
|
83
|
+
multiplying the ceiling by the factor is the right arithmetic and not an
|
|
84
|
+
approximation of one.
|
|
85
|
+
"""
|
|
86
|
+
at_one = _measure(1)
|
|
87
|
+
|
|
88
|
+
with scaled_world(_shape(max_rows=at_one * 2), 10, using=connection.alias):
|
|
89
|
+
assert EventSession.objects.count() > at_one
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_a_ceiling_that_is_still_too_low_at_the_factor_refuses_by_name() -> None:
|
|
93
|
+
"""Scaling the ceiling does not disable it."""
|
|
94
|
+
with (
|
|
95
|
+
pytest.raises(InvalidShape, match="max_rows="),
|
|
96
|
+
scaled_world(_shape(max_rows=1), 10, using=connection.alias),
|
|
97
|
+
):
|
|
98
|
+
pass # pragma: no cover - the build raises before the block runs
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _measure(factor: int) -> int:
|
|
102
|
+
with scaled_world(_shape(max_rows=None), factor, using=connection.alias):
|
|
103
|
+
return EventSession.objects.count()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/apply_statistics_targets.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/check_constraints.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/children_per_parent.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/__init__.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/after.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/aligned.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/copied.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/derivation.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/derived.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/given.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/offset.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/per_parent.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/product.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/scope.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/__init__.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/ascending.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/bounded.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/categorical.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/constant.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/distinct.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/sequential.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/skew.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/uniform.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/zipf.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/__init__.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/scale_fixture.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/shape_fixture.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/infer_key_strategy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/invariant_violated.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/key_function.py
RENAMED
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/key_strategy.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/sequential_keys.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/order_derivations.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/require_clone_strategy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape_from_factory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/template_database.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/unsupported_backend.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_canonical_arithmetic.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_sequential.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_apply_statistics_targets.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_world_restores_sequences.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|