truequery 0.1.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.
Files changed (254) hide show
  1. truequery-0.1.0/.gitignore +20 -0
  2. truequery-0.1.0/LICENSE +201 -0
  3. truequery-0.1.0/NOTICE +4 -0
  4. truequery-0.1.0/PKG-INFO +52 -0
  5. truequery-0.1.0/README.md +24 -0
  6. truequery-0.1.0/pyproject.toml +45 -0
  7. truequery-0.1.0/src/truequery/__init__.py +3 -0
  8. truequery-0.1.0/src/truequery/analyzers/__init__.py +0 -0
  9. truequery-0.1.0/src/truequery/analyzers/project_checks.py +220 -0
  10. truequery-0.1.0/src/truequery/analyzers/sql.py +529 -0
  11. truequery-0.1.0/src/truequery/checks/__init__.py +0 -0
  12. truequery-0.1.0/src/truequery/checks/sql.py +1278 -0
  13. truequery-0.1.0/src/truequery/cli.py +710 -0
  14. truequery-0.1.0/src/truequery/engine.py +346 -0
  15. truequery-0.1.0/src/truequery/hook.py +860 -0
  16. truequery-0.1.0/src/truequery/keylookup.py +135 -0
  17. truequery-0.1.0/src/truequery/models.py +32 -0
  18. truequery-0.1.0/src/truequery/project.py +561 -0
  19. truequery-0.1.0/src/truequery/registry_impl.json +127 -0
  20. truequery-0.1.0/src/truequery/report.py +343 -0
  21. truequery-0.1.0/src/truequery/schema.py +206 -0
  22. truequery-0.1.0/src/truequery/settings.py +239 -0
  23. truequery-0.1.0/src/truequery/standard/consume/README.md +111 -0
  24. truequery-0.1.0/src/truequery/standard/consume/adhoc-limit-required.yaml +50 -0
  25. truequery-0.1.0/src/truequery/standard/consume/aggregate-before-export.yaml +39 -0
  26. truequery-0.1.0/src/truequery/standard/consume/consumer-cost-guard.yaml +44 -0
  27. truequery-0.1.0/src/truequery/standard/consume/consumer-reads-marts.yaml +38 -0
  28. truequery-0.1.0/src/truequery/standard/consume/dashboard-query-budget.yaml +40 -0
  29. truequery-0.1.0/src/truequery/standard/consume/dashboard-refresh-schedule.yaml +47 -0
  30. truequery-0.1.0/src/truequery/standard/consume/deterministic-export-order.yaml +44 -0
  31. truequery-0.1.0/src/truequery/standard/consume/explicit-timezone-consumers.yaml +44 -0
  32. truequery-0.1.0/src/truequery/standard/consume/explore-answer-carries-reproducible-query.yaml +56 -0
  33. truequery-0.1.0/src/truequery/standard/consume/explore-caveats-and-unchecked-stated.yaml +52 -0
  34. truequery-0.1.0/src/truequery/standard/consume/explore-day-boundaries-and-partial-periods.yaml +51 -0
  35. truequery-0.1.0/src/truequery/standard/consume/explore-experiment-readout-follows-plan.yaml +63 -0
  36. truequery-0.1.0/src/truequery/standard/consume/explore-freshness-and-coverage-checked.yaml +54 -0
  37. truequery-0.1.0/src/truequery/standard/consume/explore-inspect-distributions-and-examples.yaml +47 -0
  38. truequery-0.1.0/src/truequery/standard/consume/explore-join-row-count-checks.yaml +53 -0
  39. truequery-0.1.0/src/truequery/standard/consume/explore-null-aware-negative-filters.yaml +50 -0
  40. truequery-0.1.0/src/truequery/standard/consume/explore-question-metric-grain-stated.yaml +55 -0
  41. truequery-0.1.0/src/truequery/standard/consume/explore-rates-not-counts-across-segments.yaml +51 -0
  42. truequery-0.1.0/src/truequery/standard/consume/explore-reconcile-to-known-total.yaml +51 -0
  43. truequery-0.1.0/src/truequery/standard/consume/explore-reuse-governed-metric.yaml +52 -0
  44. truequery-0.1.0/src/truequery/standard/consume/export-row-cap.yaml +45 -0
  45. truequery-0.1.0/src/truequery/standard/consume/freshness-displayed.yaml +44 -0
  46. truequery-0.1.0/src/truequery/standard/consume/no-deep-offset.yaml +38 -0
  47. truequery-0.1.0/src/truequery/standard/consume/parameterized-dashboard-filters.yaml +38 -0
  48. truequery-0.1.0/src/truequery/standard/consume/reverse-etl-idempotent-keys.yaml +45 -0
  49. truequery-0.1.0/src/truequery/standard/consume/reverse-etl-pii-consent.yaml +50 -0
  50. truequery-0.1.0/src/truequery/standard/consume/reverse-etl-schema-contract.yaml +47 -0
  51. truequery-0.1.0/src/truequery/standard/dq/README.md +117 -0
  52. truequery-0.1.0/src/truequery/standard/dq/accuracy-proxy-or-unmeasurable.yaml +45 -0
  53. truequery-0.1.0/src/truequery/standard/dq/audits-blocking-every-run.yaml +47 -0
  54. truequery-0.1.0/src/truequery/standard/dq/checks-versioned-with-code.yaml +52 -0
  55. truequery-0.1.0/src/truequery/standard/dq/completeness-declare-missing-sentinels.yaml +44 -0
  56. truequery-0.1.0/src/truequery/standard/dq/completeness-fill-rate-thresholds.yaml +45 -0
  57. truequery-0.1.0/src/truequery/standard/dq/completeness-not-null-required-columns.yaml +60 -0
  58. truequery-0.1.0/src/truequery/standard/dq/completeness-table-not-empty.yaml +48 -0
  59. truequery-0.1.0/src/truequery/standard/dq/consistency-cross-column-row-rules.yaml +49 -0
  60. truequery-0.1.0/src/truequery/standard/dq/consistency-no-orphan-keys.yaml +49 -0
  61. truequery-0.1.0/src/truequery/standard/dq/consistency-paired-aggregate-reconciliation.yaml +48 -0
  62. truequery-0.1.0/src/truequery/standard/dq/schema-conformance-checked-on-read.yaml +48 -0
  63. truequery-0.1.0/src/truequery/standard/dq/unenforced-constraints-are-tested.yaml +51 -0
  64. truequery-0.1.0/src/truequery/standard/dq/uniqueness-composite-grain.yaml +52 -0
  65. truequery-0.1.0/src/truequery/standard/dq/uniqueness-key-no-duplicates.yaml +53 -0
  66. truequery-0.1.0/src/truequery/standard/dq/unit-tests-with-fixtures.yaml +52 -0
  67. truequery-0.1.0/src/truequery/standard/dq/validity-allowed-value-sets.yaml +46 -0
  68. truequery-0.1.0/src/truequery/standard/dq/validity-enforce-model-contracts.yaml +51 -0
  69. truequery-0.1.0/src/truequery/standard/dq/validity-range-format-type-rules.yaml +50 -0
  70. truequery-0.1.0/src/truequery/standard/gov/README.md +94 -0
  71. truequery-0.1.0/src/truequery/standard/gov/audit-columns-or-snapshots.yaml +45 -0
  72. truequery-0.1.0/src/truequery/standard/gov/column-grants-for-pii.yaml +41 -0
  73. truequery-0.1.0/src/truequery/standard/gov/declared-model-owner.yaml +43 -0
  74. truequery-0.1.0/src/truequery/standard/gov/description-coverage-for-shared-models.yaml +40 -0
  75. truequery-0.1.0/src/truequery/standard/gov/erasure-path-documented.yaml +43 -0
  76. truequery-0.1.0/src/truequery/standard/gov/exposures-registered.yaml +73 -0
  77. truequery-0.1.0/src/truequery/standard/gov/group-private-access.yaml +41 -0
  78. truequery-0.1.0/src/truequery/standard/gov/least-privilege-grants.yaml +80 -0
  79. truequery-0.1.0/src/truequery/standard/gov/lineage-from-declared-sources.yaml +41 -0
  80. truequery-0.1.0/src/truequery/standard/gov/mesh-public-contracts-only.yaml +41 -0
  81. truequery-0.1.0/src/truequery/standard/gov/no-bypassrls-roles.yaml +39 -0
  82. truequery-0.1.0/src/truequery/standard/gov/no-public-privileges.yaml +39 -0
  83. truequery-0.1.0/src/truequery/standard/gov/no-raw-pii-in-seeds.yaml +41 -0
  84. truequery-0.1.0/src/truequery/standard/gov/pii-classification-declared.yaml +42 -0
  85. truequery-0.1.0/src/truequery/standard/gov/production-pii-not-in-dev.yaml +43 -0
  86. truequery-0.1.0/src/truequery/standard/gov/redacting-views-for-pii.yaml +41 -0
  87. truequery-0.1.0/src/truequery/standard/gov/retention-declared.yaml +42 -0
  88. truequery-0.1.0/src/truequery/standard/gov/row-policy-for-sensitive-tables.yaml +38 -0
  89. truequery-0.1.0/src/truequery/standard/ingest/README.md +100 -0
  90. truequery-0.1.0/src/truequery/standard/ingest/cap-intake-cost-and-volume.yaml +46 -0
  91. truequery-0.1.0/src/truequery/standard/ingest/cdc-replica-identity-required.yaml +47 -0
  92. truequery-0.1.0/src/truequery/standard/ingest/checkpoint-streaming-intake.yaml +42 -0
  93. truequery-0.1.0/src/truequery/standard/ingest/choose-batch-vs-streaming-deliberately.yaml +45 -0
  94. truequery-0.1.0/src/truequery/standard/ingest/declare-source-freshness.yaml +80 -0
  95. truequery-0.1.0/src/truequery/standard/ingest/dedupe-on-natural-key-before-append.yaml +45 -0
  96. truequery-0.1.0/src/truequery/standard/ingest/handle-schema-drift-explicitly.yaml +45 -0
  97. truequery-0.1.0/src/truequery/standard/ingest/idempotent-batch-loads.yaml +49 -0
  98. truequery-0.1.0/src/truequery/standard/ingest/isolate-source-failures.yaml +50 -0
  99. truequery-0.1.0/src/truequery/standard/ingest/landing-rebuildable-from-source.yaml +43 -0
  100. truequery-0.1.0/src/truequery/standard/ingest/monitor-cdc-lag-and-slots.yaml +47 -0
  101. truequery-0.1.0/src/truequery/standard/ingest/pin-connector-and-schema-versions.yaml +42 -0
  102. truequery-0.1.0/src/truequery/standard/ingest/pin-file-format-options.yaml +42 -0
  103. truequery-0.1.0/src/truequery/standard/ingest/propagate-deletes-explicitly.yaml +48 -0
  104. truequery-0.1.0/src/truequery/standard/ingest/quarantine-invalid-rows-at-intake.yaml +56 -0
  105. truequery-0.1.0/src/truequery/standard/ingest/raw-landing-append-only.yaml +48 -0
  106. truequery-0.1.0/src/truequery/standard/ingest/reconcile-row-counts-per-load.yaml +43 -0
  107. truequery-0.1.0/src/truequery/standard/ingest/record-file-lineage-at-intake.yaml +48 -0
  108. truequery-0.1.0/src/truequery/standard/ingest/reference-sources-not-raw-tables.yaml +42 -0
  109. truequery-0.1.0/src/truequery/standard/ingest/require-completeness-marker.yaml +50 -0
  110. truequery-0.1.0/src/truequery/standard/ingest/scan-pii-at-landing.yaml +45 -0
  111. truequery-0.1.0/src/truequery/standard/ingest/seeds-small-static-only.yaml +43 -0
  112. truequery-0.1.0/src/truequery/standard/ingest/test-intake-against-fixtures.yaml +46 -0
  113. truequery-0.1.0/src/truequery/standard/ingest/watermark-and-late-data-policy.yaml +49 -0
  114. truequery-0.1.0/src/truequery/standard/model/README.md +91 -0
  115. truequery-0.1.0/src/truequery/standard/model/dbt-contract-enforced.yaml +50 -0
  116. truequery-0.1.0/src/truequery/standard/model/delete-handling-incremental.yaml +51 -0
  117. truequery-0.1.0/src/truequery/standard/model/explicit-column-lists.yaml +83 -0
  118. truequery-0.1.0/src/truequery/standard/model/full-refresh-parity.yaml +49 -0
  119. truequery-0.1.0/src/truequery/standard/model/grain-preserved-joins.yaml +52 -0
  120. truequery-0.1.0/src/truequery/standard/model/idempotent-reexec.yaml +48 -0
  121. truequery-0.1.0/src/truequery/standard/model/incremental-lookback-window.yaml +53 -0
  122. truequery-0.1.0/src/truequery/standard/model/incremental-watermark-filter.yaml +48 -0
  123. truequery-0.1.0/src/truequery/standard/model/jinja-macro-determinism.yaml +46 -0
  124. truequery-0.1.0/src/truequery/standard/model/jinja-no-nested-curlies.yaml +43 -0
  125. truequery-0.1.0/src/truequery/standard/model/materialization-choice.yaml +51 -0
  126. truequery-0.1.0/src/truequery/standard/model/merge-source-deduped.yaml +57 -0
  127. truequery-0.1.0/src/truequery/standard/model/microbatch-event-time.yaml +39 -0
  128. truequery-0.1.0/src/truequery/standard/model/null-join-keys-excluded.yaml +45 -0
  129. truequery-0.1.0/src/truequery/standard/model/snapshot-scd2-validity.yaml +45 -0
  130. truequery-0.1.0/src/truequery/standard/model/snapshot-strategy-choice.yaml +41 -0
  131. truequery-0.1.0/src/truequery/standard/model/staging-no-business-logic.yaml +44 -0
  132. truequery-0.1.0/src/truequery/standard/model/surrogate-keys-stable.yaml +37 -0
  133. truequery-0.1.0/src/truequery/standard/model/unique-key-merge-key.yaml +55 -0
  134. truequery-0.1.0/src/truequery/standard/ops/README.md +98 -0
  135. truequery-0.1.0/src/truequery/standard/ops/breaking-change-categorization.yaml +35 -0
  136. truequery-0.1.0/src/truequery/standard/ops/ci-pr-checks-required.yaml +44 -0
  137. truequery-0.1.0/src/truequery/standard/ops/ci-slim-builds-only-changed.yaml +42 -0
  138. truequery-0.1.0/src/truequery/standard/ops/cost-estimate-before-run.yaml +41 -0
  139. truequery-0.1.0/src/truequery/standard/ops/cost-guardrail-confidence-levels.yaml +39 -0
  140. truequery-0.1.0/src/truequery/standard/ops/dev-environment-expiry.yaml +42 -0
  141. truequery-0.1.0/src/truequery/standard/ops/disposable-dev-environments.yaml +42 -0
  142. truequery-0.1.0/src/truequery/standard/ops/drift-detection-history-first.yaml +42 -0
  143. truequery-0.1.0/src/truequery/standard/ops/full-refresh-approval.yaml +76 -0
  144. truequery-0.1.0/src/truequery/standard/ops/model-versioning-breaking-changes.yaml +83 -0
  145. truequery-0.1.0/src/truequery/standard/ops/plan-preview-before-apply.yaml +39 -0
  146. truequery-0.1.0/src/truequery/standard/ops/post-deploy-data-validation.yaml +42 -0
  147. truequery-0.1.0/src/truequery/standard/ops/pre-destructive-snapshot.yaml +35 -0
  148. truequery-0.1.0/src/truequery/standard/ops/prod-credentials-isolation.yaml +96 -0
  149. truequery-0.1.0/src/truequery/standard/ops/run-artifact-retention.yaml +41 -0
  150. truequery-0.1.0/src/truequery/standard/ops/staged-upgrades-with-backup.yaml +39 -0
  151. truequery-0.1.0/src/truequery/standard/orch/README.md +74 -0
  152. truequery-0.1.0/src/truequery/standard/orch/concurrency-pools-and-limits.yaml +63 -0
  153. truequery-0.1.0/src/truequery/standard/orch/dag-ci-parse-and-unit-tests.yaml +70 -0
  154. truequery-0.1.0/src/truequery/standard/orch/data-aware-scheduling-over-polling.yaml +62 -0
  155. truequery-0.1.0/src/truequery/standard/orch/declared-asset-lineage.yaml +66 -0
  156. truequery-0.1.0/src/truequery/standard/orch/deferrable-sensors-with-timeout.yaml +75 -0
  157. truequery-0.1.0/src/truequery/standard/orch/explicit-catchup-policy.yaml +53 -0
  158. truequery-0.1.0/src/truequery/standard/orch/explicit-schedule-timezone.yaml +68 -0
  159. truequery-0.1.0/src/truequery/standard/orch/failure-alert-routing.yaml +100 -0
  160. truequery-0.1.0/src/truequery/standard/orch/idempotent-backfill-windowing.yaml +68 -0
  161. truequery-0.1.0/src/truequery/standard/orch/idempotent-retries-with-limits.yaml +79 -0
  162. truequery-0.1.0/src/truequery/standard/orch/light-dag-parse-no-heavy-top-level.yaml +75 -0
  163. truequery-0.1.0/src/truequery/standard/orch/no-circular-dependencies.yaml +67 -0
  164. truequery-0.1.0/src/truequery/standard/orch/partitioned-assets-windowing.yaml +66 -0
  165. truequery-0.1.0/src/truequery/standard/orch/sla-deadline-alerts.yaml +76 -0
  166. truequery-0.1.0/src/truequery/standard/orch/task-atomicity-no-partial-writes.yaml +62 -0
  167. truequery-0.1.0/src/truequery/standard/orch/task-timeout-execution-limit.yaml +70 -0
  168. truequery-0.1.0/src/truequery/standard/py/README.md +63 -0
  169. truequery-0.1.0/src/truequery/standard/py/airflow-isolate-task-dependencies.yaml +40 -0
  170. truequery-0.1.0/src/truequery/standard/py/dagster-asset-declared-dependencies.yaml +47 -0
  171. truequery-0.1.0/src/truequery/standard/py/dagster-io-manager-not-manual-io.yaml +47 -0
  172. truequery-0.1.0/src/truequery/standard/py/dagster-resources-for-external-clients.yaml +53 -0
  173. truequery-0.1.0/src/truequery/standard/py/dbt-python-model-contract.yaml +48 -0
  174. truequery-0.1.0/src/truequery/standard/py/deterministic-model-outputs.yaml +83 -0
  175. truequery-0.1.0/src/truequery/standard/py/hook-adapter-connection-lifecycle.yaml +59 -0
  176. truequery-0.1.0/src/truequery/standard/py/idempotent-task-logic.yaml +55 -0
  177. truequery-0.1.0/src/truequery/standard/py/no-n-plus-one-queries-in-loops.yaml +46 -0
  178. truequery-0.1.0/src/truequery/standard/py/pandas-filter-before-collect.yaml +44 -0
  179. truequery-0.1.0/src/truequery/standard/py/pandas-no-chained-assignment.yaml +41 -0
  180. truequery-0.1.0/src/truequery/standard/py/pandas-no-row-loop-mutations.yaml +44 -0
  181. truequery-0.1.0/src/truequery/standard/py/pin-pipeline-dependencies.yaml +82 -0
  182. truequery-0.1.0/src/truequery/standard/py/sqlmesh-audit-python-outputs.yaml +49 -0
  183. truequery-0.1.0/src/truequery/standard/py/sqlmesh-python-model-execution-context.yaml +52 -0
  184. truequery-0.1.0/src/truequery/standard/sem/README.md +97 -0
  185. truequery-0.1.0/src/truequery/standard/sem/aggregation-type-matches-additivity.yaml +61 -0
  186. truequery-0.1.0/src/truequery/standard/sem/conversion-metrics-window-bounds.yaml +54 -0
  187. truequery-0.1.0/src/truequery/standard/sem/count-distinct-uses-entity-key.yaml +52 -0
  188. truequery-0.1.0/src/truequery/standard/sem/cumulative-metrics-time-spine.yaml +53 -0
  189. truequery-0.1.0/src/truequery/standard/sem/derived-metrics-compose-from-governed.yaml +52 -0
  190. truequery-0.1.0/src/truequery/standard/sem/description-and-ownership-per-metric.yaml +50 -0
  191. truequery-0.1.0/src/truequery/standard/sem/dimension-naming-conventions.yaml +52 -0
  192. truequery-0.1.0/src/truequery/standard/sem/entity-primary-key-declared.yaml +54 -0
  193. truequery-0.1.0/src/truequery/standard/sem/join-paths-declared-via-entities.yaml +47 -0
  194. truequery-0.1.0/src/truequery/standard/sem/metric-filters-declared-not-hidden.yaml +57 -0
  195. truequery-0.1.0/src/truequery/standard/sem/metric-grain-declaration.yaml +52 -0
  196. truequery-0.1.0/src/truequery/standard/sem/metric-smoke-test-on-change.yaml +43 -0
  197. truequery-0.1.0/src/truequery/standard/sem/no-fanout-double-counting.yaml +52 -0
  198. truequery-0.1.0/src/truequery/standard/sem/no-metric-defined-off-staging.yaml +47 -0
  199. truequery-0.1.0/src/truequery/standard/sem/null-handling-in-aggregations.yaml +57 -0
  200. truequery-0.1.0/src/truequery/standard/sem/percentile-metrics-use-approximate.yaml +51 -0
  201. truequery-0.1.0/src/truequery/standard/sem/ratio-metrics-divide-after-aggregation.yaml +49 -0
  202. truequery-0.1.0/src/truequery/standard/sem/saved-query-canonical-slices.yaml +56 -0
  203. truequery-0.1.0/src/truequery/standard/sem/semantic-model-validates.yaml +50 -0
  204. truequery-0.1.0/src/truequery/standard/sem/single-governed-metric-definition.yaml +68 -0
  205. truequery-0.1.0/src/truequery/standard/sem/time-dimension-standardized.yaml +51 -0
  206. truequery-0.1.0/src/truequery/standard/sem/unit-consistency.yaml +54 -0
  207. truequery-0.1.0/src/truequery/standard/sql/README.md +126 -0
  208. truequery-0.1.0/src/truequery/standard/sql/accidental-cross-join.yaml +58 -0
  209. truequery-0.1.0/src/truequery/standard/sql/average-of-ratios.yaml +63 -0
  210. truequery-0.1.0/src/truequery/standard/sql/between-date-on-timestamp.yaml +74 -0
  211. truequery-0.1.0/src/truequery/standard/sql/case-without-else-in-aggregate.yaml +67 -0
  212. truequery-0.1.0/src/truequery/standard/sql/count-star-after-left-join.yaml +67 -0
  213. truequery-0.1.0/src/truequery/standard/sql/distinct-dedup-bandaid.yaml +59 -0
  214. truequery-0.1.0/src/truequery/standard/sql/explore-limit-is-not-a-sample.yaml +56 -0
  215. truequery-0.1.0/src/truequery/standard/sql/explore-profile-filter-columns.yaml +48 -0
  216. truequery-0.1.0/src/truequery/standard/sql/fanout-join-pre-aggregation.yaml +64 -0
  217. truequery-0.1.0/src/truequery/standard/sql/group-by-bare-column.yaml +75 -0
  218. truequery-0.1.0/src/truequery/standard/sql/insert-explicit-column-list.yaml +60 -0
  219. truequery-0.1.0/src/truequery/standard/sql/integer-division-truncation.yaml +94 -0
  220. truequery-0.1.0/src/truequery/standard/sql/keyset-pagination.yaml +70 -0
  221. truequery-0.1.0/src/truequery/standard/sql/left-join-null-rejecting-where.yaml +58 -0
  222. truequery-0.1.0/src/truequery/standard/sql/limit-requires-order-by.yaml +67 -0
  223. truequery-0.1.0/src/truequery/standard/sql/natural-join-explicit-keys.yaml +56 -0
  224. truequery-0.1.0/src/truequery/standard/sql/negative-filter-drops-nulls.yaml +70 -0
  225. truequery-0.1.0/src/truequery/standard/sql/nondeterministic-merge-keys.yaml +69 -0
  226. truequery-0.1.0/src/truequery/standard/sql/not-in-nullable-subquery.yaml +57 -0
  227. truequery-0.1.0/src/truequery/standard/sql/null-equality-comparison.yaml +65 -0
  228. truequery-0.1.0/src/truequery/standard/sql/random-sampling-no-sort.yaml +48 -0
  229. truequery-0.1.0/src/truequery/standard/sql/row-number-dedupe-tiebreaker.yaml +67 -0
  230. truequery-0.1.0/src/truequery/standard/sql/sargable-filter-bare-column.yaml +53 -0
  231. truequery-0.1.0/src/truequery/standard/sql/set-operation-column-position.yaml +59 -0
  232. truequery-0.1.0/src/truequery/standard/sql/unguarded-update-delete.yaml +63 -0
  233. truequery-0.1.0/src/truequery/standard/sql/union-all-default.yaml +70 -0
  234. truequery-0.1.0/src/truequery/standard/store/README.md +88 -0
  235. truequery-0.1.0/src/truequery/standard/store/cluster-on-frequent-filters-joins.yaml +44 -0
  236. truequery-0.1.0/src/truequery/standard/store/compact-small-files-optimize.yaml +44 -0
  237. truequery-0.1.0/src/truequery/standard/store/declare-not-null-check-constraints.yaml +43 -0
  238. truequery-0.1.0/src/truequery/standard/store/declare-sort-order-for-range-queries.yaml +44 -0
  239. truequery-0.1.0/src/truequery/standard/store/enable-change-feed-for-incremental-consumers.yaml +44 -0
  240. truequery-0.1.0/src/truequery/standard/store/evolve-partitions-by-metadata-not-rewrite.yaml +45 -0
  241. truequery-0.1.0/src/truequery/standard/store/explicit-physical-types-no-implicit-casts.yaml +43 -0
  242. truequery-0.1.0/src/truequery/standard/store/full-refresh-by-replace-not-delete-insert.yaml +44 -0
  243. truequery-0.1.0/src/truequery/standard/store/incremental-watermark-partition-alignment.yaml +40 -0
  244. truequery-0.1.0/src/truequery/standard/store/no-high-cardinality-partition-column.yaml +47 -0
  245. truequery-0.1.0/src/truequery/standard/store/partition-expiration-retention-policy.yaml +43 -0
  246. truequery-0.1.0/src/truequery/standard/store/partition-on-filter-column.yaml +43 -0
  247. truequery-0.1.0/src/truequery/standard/store/partition-predicate-required.yaml +41 -0
  248. truequery-0.1.0/src/truequery/standard/store/prefer-auto-liquid-clustering-over-manual-tune.yaml +37 -0
  249. truequery-0.1.0/src/truequery/standard/store/rewrite-manifests-and-stats-periodically.yaml +37 -0
  250. truequery-0.1.0/src/truequery/standard/store/single-open-format-per-medallion-layer.yaml +37 -0
  251. truequery-0.1.0/src/truequery/standard/store/time-travel-retention-explicit.yaml +46 -0
  252. truequery-0.1.0/src/truequery/standard/store/use-transient-temporary-for-ephemeral.yaml +35 -0
  253. truequery-0.1.0/src/truequery/standard/store/vacuum-expire-snapshots-with-retention-floor.yaml +42 -0
  254. truequery-0.1.0/src/truequery/std_registry.py +3310 -0
@@ -0,0 +1,20 @@
1
+ # Python
2
+ .venv/
3
+ __pycache__/
4
+ *.pyc
5
+ *.egg-info/
6
+ build/
7
+ dist/
8
+ .pytest_cache/
9
+
10
+ # TrueQuery's own per-project state
11
+ .truequery/
12
+
13
+ # Generated demo data (each folder documents how to rebuild it)
14
+ *.duckdb
15
+ *.duckdb.wal
16
+
17
+ # Local working notes, never published
18
+ internal/
19
+
20
+ .DS_Store
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
truequery-0.1.0/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ TrueQuery — Copyright Analytically.ai
2
+
3
+ This product includes software developed by Analytically.ai.
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.5
2
+ Name: truequery
3
+ Version: 0.1.0
4
+ Summary: TrueQuery engine: offline, deterministic checks for SQL that silently returns the wrong answer
5
+ Project-URL: Homepage, https://github.com/Analytically-ai/truequery
6
+ Project-URL: Issues, https://github.com/Analytically-ai/truequery/issues
7
+ Author: Analytically.ai
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ License-File: NOTICE
11
+ Keywords: analytics,data-engineering,dbt,lint,sql
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Database
20
+ Classifier: Topic :: Software Development :: Quality Assurance
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: pyyaml==6.0.3
23
+ Requires-Dist: sqlglot==30.22.0
24
+ Provides-Extra: test
25
+ Requires-Dist: duckdb; extra == 'test'
26
+ Requires-Dist: pytest; extra == 'test'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # TrueQuery engine
30
+
31
+ The offline checker behind [TrueQuery](https://github.com/Analytically-ai/truequery).
32
+ It installs two commands, `truequery` and its short alias `tq`.
33
+
34
+ ```bash
35
+ pip install truequery
36
+ uvx truequery detect .
37
+ ```
38
+
39
+ It looks for SQL that silently returns the wrong answer: a `NOT IN` that one
40
+ NULL empties, a `WHERE` that turns a `LEFT JOIN` into an inner join, a
41
+ `COUNT(*)` that counts missing rows, an unguarded `UPDATE` or `DELETE`.
42
+ Twenty-five checks ship with the preview, 15 of them on by default, each
43
+ promoted only when it proves precise on real projects. Files it can't parse,
44
+ can't decode, or that are over the 10 MB limit are listed as not checked,
45
+ never as clean.
46
+
47
+ It runs offline and gives deterministic output, with no LLM and no network
48
+ calls: plain code on your machine, in well under a second per file. Text,
49
+ JSON and SARIF output; exit codes 0 (clean), 1 (findings), 2 (usage or config
50
+ error) and 3 (some files couldn't be checked). See the
51
+ [repository README](https://github.com/Analytically-ai/truequery) for the
52
+ full guide: the skill, the receipt, hooks, and the standard behind the checks.
@@ -0,0 +1,24 @@
1
+ # TrueQuery engine
2
+
3
+ The offline checker behind [TrueQuery](https://github.com/Analytically-ai/truequery).
4
+ It installs two commands, `truequery` and its short alias `tq`.
5
+
6
+ ```bash
7
+ pip install truequery
8
+ uvx truequery detect .
9
+ ```
10
+
11
+ It looks for SQL that silently returns the wrong answer: a `NOT IN` that one
12
+ NULL empties, a `WHERE` that turns a `LEFT JOIN` into an inner join, a
13
+ `COUNT(*)` that counts missing rows, an unguarded `UPDATE` or `DELETE`.
14
+ Twenty-five checks ship with the preview, 15 of them on by default, each
15
+ promoted only when it proves precise on real projects. Files it can't parse,
16
+ can't decode, or that are over the 10 MB limit are listed as not checked,
17
+ never as clean.
18
+
19
+ It runs offline and gives deterministic output, with no LLM and no network
20
+ calls: plain code on your machine, in well under a second per file. Text,
21
+ JSON and SARIF output; exit codes 0 (clean), 1 (findings), 2 (usage or config
22
+ error) and 3 (some files couldn't be checked). See the
23
+ [repository README](https://github.com/Analytically-ai/truequery) for the
24
+ full guide: the skill, the receipt, hooks, and the standard behind the checks.
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ # hatchling builds out of tree: running the engine straight from an
3
+ # installed plugin (uv run --with-editable <plugin>/engine) writes nothing
4
+ # into it; the plugin's scripts send bytecode to ~/.cache/truequery.
5
+ requires = ["hatchling>=1.27"]
6
+ build-backend = "hatchling.build"
7
+
8
+ [project]
9
+ name = "truequery"
10
+ version = "0.1.0"
11
+ description = "TrueQuery engine: offline, deterministic checks for SQL that silently returns the wrong answer"
12
+ readme = "README.md"
13
+ requires-python = ">=3.11"
14
+ license = "Apache-2.0"
15
+ license-files = ["LICENSE", "NOTICE"]
16
+ dependencies = ["sqlglot==30.22.0", "pyyaml==6.0.3"]
17
+
18
+ authors = [{ name = "Analytically.ai" }]
19
+ keywords = ["sql", "analytics", "data-engineering", "lint", "dbt"]
20
+ classifiers = [
21
+ "Development Status :: 3 - Alpha",
22
+ "Intended Audience :: Developers",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
28
+ "Topic :: Database",
29
+ "Topic :: Software Development :: Quality Assurance",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/Analytically-ai/truequery"
34
+ Issues = "https://github.com/Analytically-ai/truequery/issues"
35
+
36
+ [project.optional-dependencies]
37
+ test = ["duckdb", "pytest"]
38
+
39
+ [project.scripts]
40
+ truequery = "truequery.cli:main"
41
+ tq = "truequery.cli:main"
42
+
43
+ [tool.hatch.build.targets.wheel]
44
+ packages = ["src/truequery"]
45
+ exclude = ["**/__pycache__"]
@@ -0,0 +1,3 @@
1
+ """TrueQuery: one standard for data work, enforced on every edit."""
2
+
3
+ __version__ = "0.1.0"
File without changes
@@ -0,0 +1,220 @@
1
+ """Preview non-SQL checks (v1, Stop tier, never immediate).
2
+
3
+ Each check is backed by an existing standard practice (cited in its
4
+ ``why``); practices with no detector-shaped record yet (Airflow dynamic
5
+ ``start_date``, pandas ``merge(validate=)``) are NOT implemented here —
6
+ they are listed as gaps in docs. Deterministic, offline, file/project
7
+ evidence only.
8
+ """
9
+ import ast
10
+ import os
11
+ import re
12
+
13
+ import yaml
14
+
15
+ INCREMENTAL = re.compile(r"materialized\s*=\s*['\"]incremental['\"]")
16
+ UNIQUE_KEY = re.compile(r"unique_key\s*=")
17
+
18
+
19
+ def _finding(rule, registry, settings, mode, path, line, why, fix,
20
+ snippet=""):
21
+ record = registry.RECORDS.get(rule) if registry else None
22
+ sev = None
23
+ if settings:
24
+ sev = settings.get(rule, {}).get("severity")
25
+ if not sev and record:
26
+ sev = record["severity"].get(mode, "warning")
27
+ return {"rule": rule, "severity": sev or "warning", "mode": mode,
28
+ "evidence": "project", "file": path, "line": line, "col": 1,
29
+ "snippet": snippet[:120], "why": why, "fix": fix}
30
+
31
+
32
+ STRATEGY = re.compile(r"incremental_strategy\s*=\s*['\"]([\w+]+)['\"]")
33
+
34
+
35
+ def _yaml_unique_key(path):
36
+ """True when a properties YAML next to the model sets unique_key in
37
+ the model's config block (dbt allows config there as well as in
38
+ the SQL)."""
39
+ model = os.path.splitext(os.path.basename(path))[0]
40
+ directory = os.path.dirname(os.path.abspath(path))
41
+ try:
42
+ names = sorted(os.listdir(directory))
43
+ except OSError:
44
+ return False
45
+ for name in names:
46
+ if not name.endswith((".yml", ".yaml")):
47
+ continue
48
+ try:
49
+ with open(os.path.join(directory, name), encoding="utf-8") as handle:
50
+ doc = yaml.safe_load(handle)
51
+ except (OSError, ValueError, yaml.YAMLError):
52
+ continue
53
+ specs = doc.get("models") if isinstance(doc, dict) else None
54
+ for spec in specs or []:
55
+ if (isinstance(spec, dict) and spec.get("name") == model
56
+ and isinstance(spec.get("config"), dict)
57
+ and spec["config"].get("unique_key")):
58
+ return True
59
+ return False
60
+
61
+
62
+ def check_dbt_model(text, path, mode="build", registry=None,
63
+ settings=None):
64
+ """model/unique-key-merge-key: merge/delete+insert incremental
65
+ model with no unique_key (in the SQL config or the model's YAML).
66
+ Microbatch/insert_overwrite strategies key on event_time/partitions
67
+ instead — no unique_key expected."""
68
+ out = []
69
+ m = INCREMENTAL.search(text)
70
+ strat = STRATEGY.search(text)
71
+ merge_like = strat is None or strat.group(1) in (
72
+ "merge", "delete+insert", "delete_insert")
73
+ if (m and merge_like and not UNIQUE_KEY.search(text)
74
+ and not _yaml_unique_key(path)):
75
+ line = text[:m.start()].count("\n") + 1
76
+ out.append(_finding(
77
+ "model/unique-key-merge-key", registry, settings, mode, path,
78
+ line,
79
+ "incremental model declares no unique_key; a merge degrades "
80
+ "to append and duplicates rows on every re-run "
81
+ "(model/unique-key-merge-key)",
82
+ "add unique_key='<key>' to the model config and a "
83
+ "unique + not_null test on the key"))
84
+ return out
85
+
86
+
87
+ def _tests_of(entry):
88
+ tests = set()
89
+ for t in entry.get("tests") or []:
90
+ tests.add(t if isinstance(t, str) else next(iter(t), ""))
91
+ for t in entry.get("data_tests") or []:
92
+ tests.add(t if isinstance(t, str) else next(iter(t), ""))
93
+ return tests
94
+
95
+
96
+ def check_schema_yaml(text, path, mode="build", registry=None,
97
+ settings=None):
98
+ """dq/uniqueness-key-no-duplicates + ingest/declare-source-freshness
99
+ over a dbt schema YAML (models:/sources:)."""
100
+ out = []
101
+ try:
102
+ doc = yaml.safe_load(text)
103
+ except Exception:
104
+ return out
105
+ if not isinstance(doc, dict):
106
+ return out
107
+ lines = text.splitlines()
108
+
109
+ def line_of(needle, after=0):
110
+ for i, row in enumerate(lines[after:], start=after + 1):
111
+ if needle in row:
112
+ return i
113
+ return 1
114
+
115
+ for model in doc.get("models") or []:
116
+ if not isinstance(model, dict):
117
+ continue
118
+ name = model.get("name", "")
119
+ cols = model.get("columns") or []
120
+ # A key candidate needs a declared signal: a MetricFlow primary
121
+ # entity, or a unique test (someone claimed uniqueness). A bare
122
+ # *_id column is as often a foreign key, and a column with an
123
+ # accepted_values test is not a key — stay silent there.
124
+ key_cols = []
125
+ for c in cols:
126
+ if not isinstance(c, dict):
127
+ continue
128
+ entity = c.get("entity") or {}
129
+ if entity.get("type") == "primary" or "unique" in _tests_of(c):
130
+ key_cols.append(c)
131
+ if not key_cols:
132
+ continue # no declared key candidate: cannot infer, stay silent
133
+ col = key_cols[0]
134
+ tests = _tests_of(col)
135
+ combo = any("unique_combination_of_columns" in t
136
+ for t in _tests_of(model))
137
+ if combo or {"unique", "not_null"} <= tests:
138
+ continue
139
+ out.append(_finding(
140
+ "dq/uniqueness-key-no-duplicates", registry, settings, mode,
141
+ path, line_of(str(col.get("name"))),
142
+ f"model {name}: key column {col.get('name')} lacks a "
143
+ "unique + not_null test pair, so duplicate or null keys "
144
+ "pass silently (dq/uniqueness-key-no-duplicates)",
145
+ f"add unique and not_null tests on {col.get('name')}, or a "
146
+ "unique_combination_of_columns test on the model"))
147
+ for source in doc.get("sources") or []:
148
+ if not isinstance(source, dict):
149
+ continue
150
+ for table in source.get("tables") or []:
151
+ if not isinstance(table, dict):
152
+ continue
153
+ freshness = source.get("freshness") or table.get("freshness")
154
+ loaded = (source.get("loaded_at_field")
155
+ or table.get("loaded_at_field"))
156
+ # Fire only on intent: the source tracks its load time but
157
+ # never checks it. A source with no loaded_at_field at all
158
+ # has not opted into freshness — stay silent.
159
+ if freshness or not loaded:
160
+ continue
161
+ out.append(_finding(
162
+ "ingest/declare-source-freshness", registry, settings,
163
+ mode, path, line_of(str(table.get("name", ""))),
164
+ f"source table {table.get('name')} tracks loaded_at_field "
165
+ "but declares no freshness check, so a stalled source is "
166
+ "invisible (ingest/declare-source-freshness)",
167
+ "add freshness: {warn_after/error_after} to the source"))
168
+ return out
169
+
170
+
171
+ def check_python(text, path, mode="build", registry=None, settings=None):
172
+ """orch/explicit-catchup-policy: Airflow DAG without catchup."""
173
+ out = []
174
+ try:
175
+ tree = ast.parse(text)
176
+ except SyntaxError:
177
+ return out
178
+ for node in ast.walk(tree):
179
+ if not isinstance(node, ast.Call):
180
+ continue
181
+ func = node.func
182
+ name = (func.id if isinstance(func, ast.Name)
183
+ else func.attr if isinstance(func, ast.Attribute) else "")
184
+ if name not in ("DAG", "dag"): # DAG(...), models.DAG, @dag(...)
185
+ continue
186
+ kws = {k.arg for k in node.keywords if k.arg}
187
+ if "catchup" in kws:
188
+ continue
189
+ out.append(_finding(
190
+ "orch/explicit-catchup-policy", registry, settings, mode,
191
+ path, node.lineno,
192
+ "Airflow DAG declares no explicit catchup; the default "
193
+ "backfills every missed interval on first deploy "
194
+ "(orch/explicit-catchup-policy)",
195
+ "set catchup=False (or True deliberately) on the DAG"))
196
+ return out
197
+
198
+
199
+ def check_aux_file(text, path, mode="build", registry=None, settings=None):
200
+ """Dispatch by file kind. Returns finding dicts (engine shape)."""
201
+ if path.endswith(".py"):
202
+ return check_python(text, path, mode, registry, settings)
203
+ if path.endswith((".yml", ".yaml")):
204
+ return check_schema_yaml(text, path, mode, registry, settings)
205
+ return []
206
+
207
+
208
+ def check_model_sql(text, path, mode="build", registry=None, settings=None):
209
+ if path.endswith(".sql"):
210
+ return check_dbt_model(text, path, mode, registry, settings)
211
+ return []
212
+
213
+
214
+ # slug -> implementing function, for the standard<->checks CI test.
215
+ PREVIEW_CHECKS = {
216
+ "model/unique-key-merge-key": check_dbt_model,
217
+ "dq/uniqueness-key-no-duplicates": check_schema_yaml,
218
+ "ingest/declare-source-freshness": check_schema_yaml,
219
+ "orch/explicit-catchup-policy": check_python,
220
+ }