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.
Files changed (176) hide show
  1. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/CHANGELOG.md +24 -1
  2. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/PKG-INFO +1 -1
  3. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/projection.py +26 -0
  4. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/scaled_shape.py +12 -3
  5. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/version.py +1 -1
  6. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/projections.md +6 -0
  7. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/pyproject.toml +1 -1
  8. django_data_shape-0.18.1/tests/test_scaled_projection_ceiling.py +103 -0
  9. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/CODEOWNERS +0 -0
  10. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/SECURITY.md +0 -0
  11. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/dependabot.yml +0 -0
  12. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/workflows/release.yml +0 -0
  13. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/workflows/tests.yml +0 -0
  14. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.github/workflows/upstream-drift.yml +0 -0
  15. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.gitignore +0 -0
  16. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/.pre-commit-config.yaml +0 -0
  17. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/CLAUDE.md +0 -0
  18. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/LICENSE +0 -0
  19. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/Makefile +0 -0
  20. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/README.md +0 -0
  21. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/__init__.py +0 -0
  22. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/apply_statistics_targets.py +0 -0
  23. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/build.py +0 -0
  24. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/build_result.py +0 -0
  25. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/canonical.py +0 -0
  26. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/check_constraints.py +0 -0
  27. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/check_invariants.py +0 -0
  28. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/children_per_parent.py +0 -0
  29. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/clone_database.py +0 -0
  30. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivation_queried_database.py +0 -0
  31. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/__init__.py +0 -0
  32. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/after.py +0 -0
  33. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/aligned.py +0 -0
  34. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/copied.py +0 -0
  35. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/derivation.py +0 -0
  36. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/derived.py +0 -0
  37. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/given.py +0 -0
  38. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/offset.py +0 -0
  39. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/per_parent.py +0 -0
  40. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/product.py +0 -0
  41. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/derivations/scope.py +0 -0
  42. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/__init__.py +0 -0
  43. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/ascending.py +0 -0
  44. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/bounded.py +0 -0
  45. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/categorical.py +0 -0
  46. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/constant.py +0 -0
  47. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/distinct.py +0 -0
  48. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/distribution.py +0 -0
  49. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/sequential.py +0 -0
  50. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/skew.py +0 -0
  51. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/uniform.py +0 -0
  52. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/distributions/zipf.py +0 -0
  53. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/drop_database.py +0 -0
  54. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fan_out.py +0 -0
  55. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fan_out_plan.py +0 -0
  56. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fan_out_sizes.py +0 -0
  57. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/__init__.py +0 -0
  58. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/scale_fixture.py +0 -0
  59. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/shape_fixture.py +0 -0
  60. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/fixtures/skip_unless_postgres.py +0 -0
  61. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/generate_rows.py +0 -0
  62. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/infer_key_strategy.py +0 -0
  63. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/invalid_shape.py +0 -0
  64. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/invariant.py +0 -0
  65. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/invariant_violated.py +0 -0
  66. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/__init__.py +0 -0
  67. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/disjoint.py +0 -0
  68. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/key_function.py +0 -0
  69. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/key_strategy.py +0 -0
  70. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/md5_keys.py +0 -0
  71. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/sequential_keys.py +0 -0
  72. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/sql_keys.py +0 -0
  73. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/keys/uuid_keys.py +0 -0
  74. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/order_derivations.py +0 -0
  75. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/order_tables.py +0 -0
  76. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/paired.py +0 -0
  77. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/paired_plan.py +0 -0
  78. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/py.typed +0 -0
  79. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/refuse_queries.py +0 -0
  80. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/require_clone_strategy.py +0 -0
  81. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/require_postgres.py +0 -0
  82. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/resolve_fan_out.py +0 -0
  83. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/resolve_paired.py +0 -0
  84. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/scale_protocol.py +0 -0
  85. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/scaled_world.py +0 -0
  86. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape.py +0 -0
  87. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape_digest.py +0 -0
  88. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape_from_factory.py +0 -0
  89. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/shape_not_empty.py +0 -0
  90. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/table.py +0 -0
  91. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/table_result.py +0 -0
  92. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/template_database.py +0 -0
  93. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/unhashable_shape.py +0 -0
  94. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/unsupported_backend.py +0 -0
  95. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/utils.py +0 -0
  96. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/django_data_shape/world_changed.py +0 -0
  97. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/derivations.md +0 -0
  98. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/index.md +0 -0
  99. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/invariants.md +0 -0
  100. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/keys.md +0 -0
  101. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/pytest.md +0 -0
  102. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/reference.md +0 -0
  103. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/relations.md +0 -0
  104. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/docs/statistics.md +0 -0
  105. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/mkdocs.yml +0 -0
  106. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/scripts/check-changelog +0 -0
  107. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/scripts/release-publish.sh +0 -0
  108. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/__init__.py +0 -0
  109. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/conftest.py +0 -0
  110. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/conftest_settings.py +0 -0
  111. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/__init__.py +0 -0
  112. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_after.py +0 -0
  113. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_after_units.py +0 -0
  114. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_aligned.py +0 -0
  115. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_canonical_arithmetic.py +0 -0
  116. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_derived.py +0 -0
  117. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_given.py +0 -0
  118. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/derivations/test_per_parent.py +0 -0
  119. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/__init__.py +0 -0
  120. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_constant.py +0 -0
  121. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_sequential.py +0 -0
  122. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_skew.py +0 -0
  123. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_uniform.py +0 -0
  124. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/distributions/test_zipf.py +0 -0
  125. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/__init__.py +0 -0
  126. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_key_function.py +0 -0
  127. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_md5_keys.py +0 -0
  128. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_sequential_keys.py +0 -0
  129. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/keys/test_uuid_keys.py +0 -0
  130. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/scale_protocol_consumers.py +0 -0
  131. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/scale_protocol_impostors.py +0 -0
  132. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_apply_statistics_targets.py +0 -0
  133. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build.py +0 -0
  134. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_derivations.py +0 -0
  135. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_graph.py +0 -0
  136. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_invariants.py +0 -0
  137. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_keys.py +0 -0
  138. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_m2m.py +0 -0
  139. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_portable.py +0 -0
  140. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_build_projection.py +0 -0
  141. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_check_constraints.py +0 -0
  142. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_children_per_parent.py +0 -0
  143. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_documentation.py +0 -0
  144. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_fan_out.py +0 -0
  145. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_fan_out_sizes.py +0 -0
  146. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_fixtures.py +0 -0
  147. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_generate_rows.py +0 -0
  148. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_infer_key_strategy.py +0 -0
  149. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_invariant.py +0 -0
  150. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_order_derivations.py +0 -0
  151. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_order_tables.py +0 -0
  152. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_paired.py +0 -0
  153. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_paired_plan.py +0 -0
  154. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_projection.py +0 -0
  155. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_projection_ceiling.py +0 -0
  156. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_reference_documents_the_public_surface.py +0 -0
  157. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_refuse_queries.py +0 -0
  158. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_require_clone_strategy.py +0 -0
  159. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_require_postgres.py +0 -0
  160. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_resolve_fan_out.py +0 -0
  161. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_resolve_paired.py +0 -0
  162. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scale_protocol.py +0 -0
  163. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_shape.py +0 -0
  164. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_world.py +0 -0
  165. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_world_over_a_session_world.py +0 -0
  166. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_scaled_world_restores_sequences.py +0 -0
  167. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_shape.py +0 -0
  168. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_shape_digest.py +0 -0
  169. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_shape_from_factory.py +0 -0
  170. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_table.py +0 -0
  171. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_template_database.py +0 -0
  172. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_utils.py +0 -0
  173. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/test_version.py +0 -0
  174. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/testapp/__init__.py +0 -0
  175. {django_data_shape-0.18.0 → django_data_shape-0.18.1}/tests/testapp/models.py +0 -0
  176. {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.0...HEAD
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.0
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` passes through
75
- untouched, and needs no factor of its own.** It has no declared row count to
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __version__: str = "0.18.0"
5
+ __version__: str = "0.18.1"
6
6
 
7
7
  __all__ = ["__version__"]
@@ -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
@@ -170,7 +170,7 @@ skip-magic-trailing-comma = false
170
170
  root = ["./django_data_shape"]
171
171
 
172
172
  [tool.bumpversion]
173
- current_version = "0.18.0"
173
+ current_version = "0.18.1"
174
174
  allow_dirty = false
175
175
  commit = false
176
176
  tag = false
@@ -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()