model2data 1.17.0__tar.gz → 1.18.0__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.
- {model2data-1.17.0/model2data.egg-info → model2data-1.18.0}/PKG-INFO +1 -1
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/slices.py +36 -3
- {model2data-1.17.0 → model2data-1.18.0/model2data.egg-info}/PKG-INFO +1 -1
- {model2data-1.17.0 → model2data-1.18.0}/pyproject.toml +1 -1
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_slices.py +67 -0
- {model2data-1.17.0 → model2data-1.18.0}/LICENSE +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/README.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/README_PYPI.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/LICENSE +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/VENDORED.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/base.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/column.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/enum.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/expression.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/index.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/note.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/project.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/reference.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/sticky_note.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/table.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/_classes/table_group.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/classes/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/constants.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/database.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/column.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/common.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/enum.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/generic.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/index.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/project.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/records.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/reference.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/sticky_note.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/table.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/table_group.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/table_partial.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/exceptions.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/parser/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/parser/blueprints.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/parser/parser.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/base.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/column.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/enum.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/expression.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/index.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/note.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/project.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/reference.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/renderer.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/sticky_note.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/table.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/table_group.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/utils.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/column.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/enum.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/expression.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/index.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/note.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/reference.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/renderer.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/table.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/utils.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/tools.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/cli.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/hint_tests.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/naming.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/project.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/dbt_project.yml.jinja +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/hint_macros/model2data_hint_tests.sql +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/hint_macros/model2data_parent_tests.sql +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/hint_macros/model2data_when_tests.sql +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/history_macros/model2data_history_tests.sql +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/macros/generate_schema_name.sql +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/profiles.yml.jinja +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/tests.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/defects/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/defects/apply.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/defects/checks.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/defects/presets.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/defects/report.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/core.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/days.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/faker.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/hints.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/history.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/kinds.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/options.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/parents.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/relationships.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/timeline.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/generate/when.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/guide/setup.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/guide/triage.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/guide/tune.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/check.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/columns.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/dbt.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/expression.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/graph.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/infer.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/lightdash.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/ossie.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/reader.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/semantic.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/sql.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/types.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/metrics/values.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/_yaml.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/dbml.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/document.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/dump.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/engine.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/errors.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/reader.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/types.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/model/validate.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/output.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/parse/__init__.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/parse/dbml.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/spec/PUBLISHING.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/spec/README.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/spec/examples/coffee_webshop.metrics.yml +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/spec/examples/coffee_webshop.model2data.yml +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/spec/metrics/README.md +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/spec/metrics/metrics.schema.json +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/spec/model.schema.json +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data/utils.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data.egg-info/SOURCES.txt +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data.egg-info/dependency_links.txt +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data.egg-info/entry_points.txt +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data.egg-info/requires.txt +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/model2data.egg-info/top_level.txt +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/setup.cfg +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_as_of_anchor.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_cli.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_cli_model.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_column_time_hints.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_coverage_gaps.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_days.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_dbml_parser.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_dbml_parser_fuzz.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_dbt_integration.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_dbt_naming.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_dbt_project.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_dbt_tests.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_defects.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_defects_dbt.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_defects_replay.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_defects_report.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_defects_review.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_determinism.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_distributions.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_examples_model.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_faker_name_inference.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_fast_paths.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_generation.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_guide.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_hint_tests.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_history.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_issue_lines.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_lone_country.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_cli.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_dbt.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_expression.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_lightdash.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_ossie.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_reader.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_semantic.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_spec.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_metrics_values.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_model.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_model_dbml.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_model_edges.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_model_messages.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_model_vocabulary.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_options.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_parent_dates.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_release_stress.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_reproducibility.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_row_identity.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_shaping.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_spec_alignment.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_spec_schema.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_table_seeds.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_timeline.py +0 -0
- {model2data-1.17.0 → model2data-1.18.0}/tests/test_when.py +0 -0
|
@@ -135,17 +135,50 @@ def _keeping(path: str, members: Sequence[Any], kind: ColumnKind) -> Where:
|
|
|
135
135
|
return Where(terms=alternatives, any=True)
|
|
136
136
|
|
|
137
137
|
|
|
138
|
-
def
|
|
138
|
+
def _within(path: str, start: Any, end: Any, kind: ColumnKind) -> Where:
|
|
139
|
+
"""The filter for rows whose date or timestamp `path` falls from `start` to `end`.
|
|
140
|
+
|
|
141
|
+
Both ends are included and either may be None. A timestamp's `end` given as a day
|
|
142
|
+
means all of that day, which is what a date picker's last day means.
|
|
143
|
+
"""
|
|
144
|
+
if kind not in ("date", "timestamp"):
|
|
145
|
+
raise ValueError(f"{path} is not a date or a timestamp ({kind})")
|
|
146
|
+
operators: dict[str, Any] = {}
|
|
147
|
+
if start is not None:
|
|
148
|
+
operators["gte"] = _value(start, kind, path)
|
|
149
|
+
if end is not None:
|
|
150
|
+
written = str(end)
|
|
151
|
+
if kind == "timestamp" and len(written) == 10:
|
|
152
|
+
day = dt.date.fromisoformat(_value(written, "date", path))
|
|
153
|
+
operators["lt"] = (day + dt.timedelta(days=1)).isoformat()
|
|
154
|
+
else:
|
|
155
|
+
operators["lte"] = _value(end, kind, path)
|
|
156
|
+
return Where(terms=[Where(terms=[Condition(path, operators)])])
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def filtered(
|
|
160
|
+
semantic: SemanticModel,
|
|
161
|
+
members: Mapping[str, Sequence[Any]],
|
|
162
|
+
*,
|
|
163
|
+
ranges: Optional[Mapping[str, tuple[Any, Any]]] = None,
|
|
164
|
+
) -> Filtered:
|
|
139
165
|
"""Every metric narrowed to rows whose dimension is one of its members.
|
|
140
166
|
|
|
141
|
-
`members` maps a column path to the values to keep, None for null.
|
|
142
|
-
|
|
167
|
+
`members` maps a column path to the values to keep, None for null. `ranges` maps a
|
|
168
|
+
date or timestamp column to its `(start, end)`, both included, None for open. All of
|
|
169
|
+
them together narrow as `and`. A dimension with no members keeps everything, and so
|
|
170
|
+
does a range open at both ends.
|
|
143
171
|
"""
|
|
144
172
|
wanted = {path: kept for path, kept in members.items() if len(kept) > 0}
|
|
145
173
|
terms = [
|
|
146
174
|
(path.rpartition(".")[0], _keeping(path, kept, _column(semantic, path)[1]))
|
|
147
175
|
for path, kept in wanted.items()
|
|
148
176
|
]
|
|
177
|
+
terms += [
|
|
178
|
+
(path.rpartition(".")[0], _within(path, start, end, _column(semantic, path)[1]))
|
|
179
|
+
for path, (start, end) in (ranges or {}).items()
|
|
180
|
+
if start is not None or end is not None
|
|
181
|
+
]
|
|
149
182
|
metrics = dict(semantic.metrics)
|
|
150
183
|
missed: set[str] = set()
|
|
151
184
|
for name, metric in semantic.metrics.items():
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "model2data"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.18.0"
|
|
8
8
|
description = "Turn a data model into realistic synthetic data, a runnable dbt project and metrics with known values"
|
|
9
9
|
readme = "README_PYPI.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -331,3 +331,70 @@ def test_a_metric_with_no_time_has_no_periods(semantic) -> None:
|
|
|
331
331
|
def test_a_grain_that_is_not_one_is_refused(semantic) -> None:
|
|
332
332
|
with pytest.raises(ValueError, match="fortnight"):
|
|
333
333
|
by_period(semantic, _frames(), "fortnight")
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def _within(semantic, **ranges):
|
|
337
|
+
wanted = {"orders.placed_at": ranges["placed"]} if "placed" in ranges else {}
|
|
338
|
+
if "joined" in ranges:
|
|
339
|
+
wanted["customers.joined_on"] = ranges["joined"]
|
|
340
|
+
return known_values(filtered(semantic, {}, ranges=wanted).semantic, _dated())
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def test_a_range_includes_both_ends(semantic) -> None:
|
|
344
|
+
found = _within(semantic, placed=("2025-01-05", "2025-01-06"))
|
|
345
|
+
assert found.values["revenue"].value == 50
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def test_a_timestamps_last_day_means_all_of_it(semantic) -> None:
|
|
349
|
+
found = _within(semantic, placed=("2025-01-05", "2025-01-05"))
|
|
350
|
+
assert found.values["orders_n"].value == 1 # the one at 23:59:59
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def test_an_exact_end_is_taken_as_written(semantic) -> None:
|
|
354
|
+
found = _within(semantic, placed=(None, "2025-01-05 23:00:00"))
|
|
355
|
+
assert found.values["orders_n"].value == 1
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def test_a_range_can_be_open_at_either_end(semantic) -> None:
|
|
359
|
+
assert _within(semantic, placed=("2025-01-06", None)).values["orders_n"].value == 2
|
|
360
|
+
assert _within(semantic, placed=(None, "2024-12-31")).values["orders_n"].value == 1
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def test_a_range_open_at_both_ends_keeps_everything(semantic) -> None:
|
|
364
|
+
assert _within(semantic, placed=(None, None)).to_json() == (
|
|
365
|
+
known_values(semantic, _dated()).to_json()
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
def test_a_range_on_a_date_column(semantic) -> None:
|
|
370
|
+
narrowed = filtered(semantic, {}, ranges={"customers.joined_on": ("2025-01-01", None)})
|
|
371
|
+
assert known_values(narrowed.semantic, _frames()).values["customers_n"].value == 2
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def test_a_range_narrows_with_members(semantic) -> None:
|
|
375
|
+
both = filtered(
|
|
376
|
+
semantic, {"orders.status": ["paid"]}, ranges={"orders.placed_at": ("2025-01-01", None)}
|
|
377
|
+
)
|
|
378
|
+
assert known_values(both.semantic, _dated()).values["orders_n"].value == 1
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def test_a_range_lists_what_it_cannot_reach(semantic) -> None:
|
|
382
|
+
found = filtered(semantic, {}, ranges={"orders.placed_at": ("2025-01-01", None)})
|
|
383
|
+
assert "customers_n" in found.unfiltered
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
@pytest.mark.parametrize(
|
|
387
|
+
("path", "start", "match"),
|
|
388
|
+
[
|
|
389
|
+
("orders.status", "2025-01-01", "not a date or a timestamp"),
|
|
390
|
+
("orders.placed_at", "soon", "is not a value of"),
|
|
391
|
+
],
|
|
392
|
+
)
|
|
393
|
+
def test_a_bad_range_is_refused(semantic, path, start, match) -> None:
|
|
394
|
+
with pytest.raises(ValueError, match=match):
|
|
395
|
+
filtered(semantic, {}, ranges={path: (start, None)})
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
def test_a_bad_last_day_is_refused(semantic) -> None:
|
|
399
|
+
with pytest.raises(ValueError, match="is not a value of"):
|
|
400
|
+
filtered(semantic, {}, ranges={"orders.placed_at": (None, "2025-13-01")})
|
|
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
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/sticky_note.py
RENAMED
|
File without changes
|
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/table_group.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/definitions/table_partial.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
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/__init__.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/column.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/enum.py
RENAMED
|
File without changes
|
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/index.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/note.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/project.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/reference.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/renderer.py
RENAMED
|
File without changes
|
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/table.py
RENAMED
|
File without changes
|
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/dbml/default/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/__init__.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/column.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/enum.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/expression.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/index.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/note.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/reference.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/renderer.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/table.py
RENAMED
|
File without changes
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/_vendor/pydbml/renderer/sql/default/utils.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
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/dbt/templates/macros/generate_schema_name.sql
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
|
|
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
|
{model2data-1.17.0 → model2data-1.18.0}/model2data/spec/examples/coffee_webshop.model2data.yml
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
|
|
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
|