truequery 0.1.2__tar.gz → 0.1.3__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.
- {truequery-0.1.2 → truequery-0.1.3}/PKG-INFO +1 -1
- {truequery-0.1.2 → truequery-0.1.3}/pyproject.toml +1 -1
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/__init__.py +1 -1
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/analyzers/sql.py +155 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/checks/sql.py +113 -4
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/cli.py +2 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/engine.py +4 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/hook.py +1 -0
- {truequery-0.1.2 → truequery-0.1.3}/.gitignore +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/LICENSE +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/NOTICE +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/analyzers/__init__.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/analyzers/project_checks.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/checks/__init__.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/extractors/__init__.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/extractors/python_sql.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/keylookup.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/models.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/project.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/registry_impl.json +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/report.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/schema.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/settings.py +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/adhoc-limit-required.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/aggregate-before-export.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/consumer-cost-guard.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/consumer-reads-marts.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/dashboard-query-budget.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/dashboard-refresh-schedule.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/deterministic-export-order.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explicit-timezone-consumers.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-answer-carries-reproducible-query.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-caveats-and-unchecked-stated.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-day-boundaries-and-partial-periods.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-experiment-readout-follows-plan.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-freshness-and-coverage-checked.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-inspect-distributions-and-examples.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-join-row-count-checks.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-null-aware-negative-filters.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-question-metric-grain-stated.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-rates-not-counts-across-segments.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-reconcile-to-known-total.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explore-reuse-governed-metric.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/export-row-cap.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/freshness-displayed.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/no-deep-offset.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/parameterized-dashboard-filters.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/reverse-etl-idempotent-keys.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/reverse-etl-pii-consent.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/reverse-etl-schema-contract.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/accuracy-proxy-or-unmeasurable.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/audits-blocking-every-run.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/checks-versioned-with-code.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/completeness-declare-missing-sentinels.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/completeness-fill-rate-thresholds.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/completeness-not-null-required-columns.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/completeness-table-not-empty.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/consistency-cross-column-row-rules.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/consistency-no-orphan-keys.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/consistency-paired-aggregate-reconciliation.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/schema-conformance-checked-on-read.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/unenforced-constraints-are-tested.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/uniqueness-composite-grain.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/uniqueness-key-no-duplicates.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/unit-tests-with-fixtures.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/validity-allowed-value-sets.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/validity-enforce-model-contracts.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/validity-range-format-type-rules.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/audit-columns-or-snapshots.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/column-grants-for-pii.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/declared-model-owner.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/description-coverage-for-shared-models.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/erasure-path-documented.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/exposures-registered.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/group-private-access.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/least-privilege-grants.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/lineage-from-declared-sources.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/mesh-public-contracts-only.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/no-bypassrls-roles.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/no-public-privileges.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/no-raw-pii-in-seeds.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/pii-classification-declared.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/production-pii-not-in-dev.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/redacting-views-for-pii.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/retention-declared.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/row-policy-for-sensitive-tables.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/cap-intake-cost-and-volume.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/cdc-replica-identity-required.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/checkpoint-streaming-intake.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/choose-batch-vs-streaming-deliberately.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/declare-source-freshness.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/dedupe-on-natural-key-before-append.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/handle-schema-drift-explicitly.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/idempotent-batch-loads.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/isolate-source-failures.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/landing-rebuildable-from-source.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/monitor-cdc-lag-and-slots.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/pin-connector-and-schema-versions.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/pin-file-format-options.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/propagate-deletes-explicitly.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/quarantine-invalid-rows-at-intake.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/raw-landing-append-only.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/reconcile-row-counts-per-load.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/record-file-lineage-at-intake.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/reference-sources-not-raw-tables.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/require-completeness-marker.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/scan-pii-at-landing.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/seeds-small-static-only.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/test-intake-against-fixtures.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ingest/watermark-and-late-data-policy.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/dbt-contract-enforced.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/delete-handling-incremental.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/explicit-column-lists.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/full-refresh-parity.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/grain-preserved-joins.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/idempotent-reexec.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/incremental-lookback-window.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/incremental-watermark-filter.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/jinja-macro-determinism.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/jinja-no-nested-curlies.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/materialization-choice.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/merge-source-deduped.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/microbatch-event-time.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/null-join-keys-excluded.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/snapshot-scd2-validity.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/snapshot-strategy-choice.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/staging-no-business-logic.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/surrogate-keys-stable.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/model/unique-key-merge-key.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/breaking-change-categorization.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/ci-pr-checks-required.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/ci-slim-builds-only-changed.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/cost-estimate-before-run.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/cost-guardrail-confidence-levels.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/dev-environment-expiry.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/disposable-dev-environments.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/drift-detection-history-first.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/full-refresh-approval.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/model-versioning-breaking-changes.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/plan-preview-before-apply.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/post-deploy-data-validation.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/pre-destructive-snapshot.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/prod-credentials-isolation.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/run-artifact-retention.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/ops/staged-upgrades-with-backup.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/concurrency-pools-and-limits.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/dag-ci-parse-and-unit-tests.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/data-aware-scheduling-over-polling.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/declared-asset-lineage.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/deferrable-sensors-with-timeout.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/explicit-catchup-policy.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/explicit-schedule-timezone.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/failure-alert-routing.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/idempotent-backfill-windowing.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/idempotent-retries-with-limits.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/light-dag-parse-no-heavy-top-level.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/no-circular-dependencies.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/partitioned-assets-windowing.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/sla-deadline-alerts.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/task-atomicity-no-partial-writes.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/orch/task-timeout-execution-limit.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/airflow-isolate-task-dependencies.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/dagster-asset-declared-dependencies.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/dagster-io-manager-not-manual-io.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/dagster-resources-for-external-clients.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/dbt-python-model-contract.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/deterministic-model-outputs.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/hook-adapter-connection-lifecycle.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/idempotent-task-logic.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/no-n-plus-one-queries-in-loops.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/pandas-filter-before-collect.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/pandas-no-chained-assignment.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/pandas-no-row-loop-mutations.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/pin-pipeline-dependencies.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/sqlmesh-audit-python-outputs.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/py/sqlmesh-python-model-execution-context.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/aggregation-type-matches-additivity.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/conversion-metrics-window-bounds.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/count-distinct-uses-entity-key.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/cumulative-metrics-time-spine.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/derived-metrics-compose-from-governed.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/description-and-ownership-per-metric.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/dimension-naming-conventions.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/entity-primary-key-declared.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/join-paths-declared-via-entities.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/metric-filters-declared-not-hidden.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/metric-grain-declaration.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/metric-smoke-test-on-change.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/no-fanout-double-counting.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/no-metric-defined-off-staging.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/null-handling-in-aggregations.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/percentile-metrics-use-approximate.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/ratio-metrics-divide-after-aggregation.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/saved-query-canonical-slices.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/semantic-model-validates.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/single-governed-metric-definition.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/time-dimension-standardized.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sem/unit-consistency.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/accidental-cross-join.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/average-of-ratios.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/between-date-on-timestamp.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/case-without-else-in-aggregate.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/count-star-after-left-join.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/distinct-dedup-bandaid.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/explore-limit-is-not-a-sample.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/explore-profile-filter-columns.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/fanout-join-pre-aggregation.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/group-by-bare-column.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/insert-explicit-column-list.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/integer-division-truncation.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/keyset-pagination.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/left-join-null-rejecting-where.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/limit-requires-order-by.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/natural-join-explicit-keys.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/negative-filter-drops-nulls.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/nondeterministic-merge-keys.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/not-in-nullable-subquery.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/null-equality-comparison.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/random-sampling-no-sort.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/row-number-dedupe-tiebreaker.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/sargable-filter-bare-column.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/set-operation-column-position.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/unguarded-update-delete.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/sql/union-all-default.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/README.md +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/cluster-on-frequent-filters-joins.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/compact-small-files-optimize.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/declare-not-null-check-constraints.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/declare-sort-order-for-range-queries.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/enable-change-feed-for-incremental-consumers.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/evolve-partitions-by-metadata-not-rewrite.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/explicit-physical-types-no-implicit-casts.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/full-refresh-by-replace-not-delete-insert.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/incremental-watermark-partition-alignment.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/no-high-cardinality-partition-column.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/partition-expiration-retention-policy.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/partition-on-filter-column.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/partition-predicate-required.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/prefer-auto-liquid-clustering-over-manual-tune.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/rewrite-manifests-and-stats-periodically.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/single-open-format-per-medallion-layer.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/time-travel-retention-explicit.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/use-transient-temporary-for-ephemeral.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/store/vacuum-expire-snapshots-with-retention-floor.yaml +0 -0
- {truequery-0.1.2 → truequery-0.1.3}/src/truequery/std_registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: truequery
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: TrueQuery engine: offline, deterministic checks for SQL that silently returns the wrong answer
|
|
5
5
|
Project-URL: Homepage, https://github.com/Analytically-ai/truequery
|
|
6
6
|
Project-URL: Issues, https://github.com/Analytically-ai/truequery/issues
|
|
@@ -7,7 +7,7 @@ build-backend = "hatchling.build"
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "truequery"
|
|
10
|
-
version = "0.1.
|
|
10
|
+
version = "0.1.3"
|
|
11
11
|
description = "TrueQuery engine: offline, deterministic checks for SQL that silently returns the wrong answer"
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.11"
|
|
@@ -8,9 +8,12 @@ attaches no node positions, so each rule searches its statement text
|
|
|
8
8
|
for its own anchor (documented approximation, good to the statement
|
|
9
9
|
and usually the line).
|
|
10
10
|
"""
|
|
11
|
+
import contextlib
|
|
12
|
+
import logging
|
|
11
13
|
import re
|
|
12
14
|
|
|
13
15
|
import sqlglot
|
|
16
|
+
from sqlglot import exp as _exp
|
|
14
17
|
|
|
15
18
|
from truequery import std_registry
|
|
16
19
|
from truequery.checks import sql as checks
|
|
@@ -401,6 +404,145 @@ class Locator:
|
|
|
401
404
|
_ANSI = re.compile(r"\x1b\[[0-9;]*m")
|
|
402
405
|
|
|
403
406
|
|
|
407
|
+
# -- statements sqlglot reads only as a Command ------------------------------
|
|
408
|
+
# For syntax it doesn't support, sqlglot doesn't raise: it keeps the text
|
|
409
|
+
# as an opaque exp.Command, and no check can see inside one. Whether that
|
|
410
|
+
# leaves something unchecked depends on what the statement is, judged on
|
|
411
|
+
# its leading keywords. The lists below are the whole policy.
|
|
412
|
+
#
|
|
413
|
+
# Statements that hold a query or a data change: every check is about
|
|
414
|
+
# these, so reading one only as a Command skipped them. That is a parse
|
|
415
|
+
# failure (the file is not checked; in Python the fragment is unparsed).
|
|
416
|
+
_DATA_HEADS = frozenset({
|
|
417
|
+
"SELECT", "WITH", "VALUES", "TABLE", "FROM", # queries (TABLE t, FROM-first)
|
|
418
|
+
"INSERT", "UPDATE", "DELETE", "MERGE", "REPLACE", "UPSERT", "COPY",
|
|
419
|
+
"EXPLAIN", # wraps a query; EXPLAIN ANALYZE also runs it
|
|
420
|
+
"PREPARE", # PREPARE p AS <query>
|
|
421
|
+
"DECLARE", # DECLARE c CURSOR FOR <query>
|
|
422
|
+
"DO", # an anonymous block of statements
|
|
423
|
+
"CACHE", # Spark CACHE TABLE t AS <query>
|
|
424
|
+
})
|
|
425
|
+
# CREATE / ALTER of these objects can hold a query: CREATE TABLE … AS,
|
|
426
|
+
# a view's query, a function, procedure, rule, trigger or macro body, a
|
|
427
|
+
# scheduled task's statement. A plain CREATE TABLE is here too: the
|
|
428
|
+
# Command's text can't show that no AS <query> follows.
|
|
429
|
+
_DATA_OBJECTS = frozenset({"TABLE", "VIEW", "FUNCTION", "PROCEDURE",
|
|
430
|
+
"ROUTINE", "RULE", "TRIGGER", "MACRO", "TASK"})
|
|
431
|
+
_ALTER_DATA_OBJECTS = frozenset({"VIEW"}) # ALTER VIEW v AS <query>
|
|
432
|
+
|
|
433
|
+
# Statements no check applies to: session and transaction control,
|
|
434
|
+
# permissions, maintenance, and schema objects that hold no query. A
|
|
435
|
+
# Command here skipped nothing, so it is no diagnostic.
|
|
436
|
+
_NO_CHECK_HEADS = frozenset({
|
|
437
|
+
"SET", "RESET", "SHOW", "USE", "PRAGMA", # session
|
|
438
|
+
"BEGIN", "START", "COMMIT", "END", "ROLLBACK", "ABORT", # transactions
|
|
439
|
+
"SAVEPOINT", "RELEASE",
|
|
440
|
+
"GRANT", "REVOKE", "DENY", "REASSIGN", # permissions
|
|
441
|
+
"VACUUM", "ANALYZE", "OPTIMIZE", "REINDEX", "CLUSTER", # maintenance
|
|
442
|
+
"CHECKPOINT", "DISCARD", "LOCK", "UNLOCK", "REFRESH", "MSCK", "KILL",
|
|
443
|
+
"SYSTEM",
|
|
444
|
+
"COMMENT", "SECURITY", # COMMENT ON, SECURITY LABEL
|
|
445
|
+
"LISTEN", "NOTIFY", "UNLISTEN", "LOAD", "ATTACH", "DETACH",
|
|
446
|
+
"DESCRIBE", "DESC",
|
|
447
|
+
# Run something already defined, or move a cursor: no query text here.
|
|
448
|
+
"CALL", "EXECUTE", "EXEC", "DEALLOCATE", "FETCH", "MOVE", "CLOSE",
|
|
449
|
+
"DROP", # removes an object; never holds a query
|
|
450
|
+
"TRUNCATE", # removes every row on purpose; no check is about it
|
|
451
|
+
})
|
|
452
|
+
_NO_CHECK_OBJECTS = frozenset({
|
|
453
|
+
"INDEX", "STATISTICS", "EXTENSION", "SCHEMA", "DATABASE", "SEQUENCE",
|
|
454
|
+
"TYPE", "DOMAIN", "COLLATION", "CAST", "OPERATOR", "AGGREGATE", "TEXT",
|
|
455
|
+
"ROLE", "USER", "GROUP", "POLICY", "PUBLICATION", "SUBSCRIPTION",
|
|
456
|
+
"SERVER", "FOREIGN", "EVENT", "ACCESS", "CONVERSION", "LANGUAGE",
|
|
457
|
+
"TABLESPACE", "TRANSFORM", "SECRET", "STAGE",
|
|
458
|
+
"VIRTUAL", # SQLite VIRTUAL TABLE … USING module(...)
|
|
459
|
+
"KEYSPACE", "CUSTOM", "AUTHORIZATION", "MAPPING", # Cassandra, Teradata, Hazelcast
|
|
460
|
+
})
|
|
461
|
+
# Words between CREATE / ALTER and the object they name.
|
|
462
|
+
_OBJECT_MODIFIERS = frozenset({
|
|
463
|
+
"OR", "REPLACE", "ALTER", "IF", "NOT", "EXISTS", "TEMP", "TEMPORARY",
|
|
464
|
+
"UNLOGGED", "GLOBAL", "LOCAL", "MATERIALIZED", "RECURSIVE", "TRANSIENT",
|
|
465
|
+
"SECURE", "VOLATILE", "EXTERNAL", "DYNAMIC", "ICEBERG", "HYBRID",
|
|
466
|
+
"MULTISET", "UNIQUE", "CONCURRENTLY", "CONSTRAINT", "DEFAULT",
|
|
467
|
+
"TRUSTED", "PROCEDURAL",
|
|
468
|
+
})
|
|
469
|
+
# Anything not named on either side is treated as holding a query: an
|
|
470
|
+
# unknown statement is not checked, never silently clean. (ClickHouse
|
|
471
|
+
# CREATE DICTIONARY is left unknown on purpose: its SOURCE can be a query.)
|
|
472
|
+
|
|
473
|
+
_WORD = re.compile(r"[A-Za-z_][A-Za-z_0-9]*")
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def _command_words(stmt):
|
|
477
|
+
rest = stmt.expression
|
|
478
|
+
if isinstance(rest, _exp.Literal):
|
|
479
|
+
rest = rest.name
|
|
480
|
+
elif isinstance(rest, _exp.Expression):
|
|
481
|
+
rest = rest.sql()
|
|
482
|
+
return [w.upper() for w in _WORD.findall(f"{stmt.this or ''} {rest or ''}")]
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def command_holds_query(stmt) -> bool:
|
|
486
|
+
"""True when a Command statement is one a check would have looked at
|
|
487
|
+
(see the lists above)."""
|
|
488
|
+
words = _command_words(stmt)
|
|
489
|
+
if not words:
|
|
490
|
+
return False
|
|
491
|
+
head = words[0]
|
|
492
|
+
if head in ("CREATE", "ALTER"):
|
|
493
|
+
obj = next((w for w in words[1:] if w not in _OBJECT_MODIFIERS), "")
|
|
494
|
+
if head == "ALTER":
|
|
495
|
+
return obj in _ALTER_DATA_OBJECTS
|
|
496
|
+
if obj in _DATA_OBJECTS:
|
|
497
|
+
return True
|
|
498
|
+
return obj not in _NO_CHECK_OBJECTS
|
|
499
|
+
if head in _DATA_HEADS:
|
|
500
|
+
return True
|
|
501
|
+
return head not in _NO_CHECK_HEADS
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
def unread_detail(stmt):
|
|
505
|
+
"""Why a statement wasn't checked, or None when it was: a query or
|
|
506
|
+
data change that parsed only as an opaque Command."""
|
|
507
|
+
if not isinstance(stmt, _exp.Command) or not command_holds_query(stmt):
|
|
508
|
+
return None
|
|
509
|
+
words = _command_words(stmt)
|
|
510
|
+
what = " ".join(words[:2]) if words[0] in ("CREATE", "ALTER") \
|
|
511
|
+
else words[0]
|
|
512
|
+
return (f"unsupported syntax: this {what} statement could be read "
|
|
513
|
+
"only as an opaque command, so no check looked inside it")
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def _command_line(chunk, stmt, start_line, after):
|
|
517
|
+
"""(line, end) of a Command statement in its chunk, searching from
|
|
518
|
+
`after`: its first words, any spacing. The chunk's first line when
|
|
519
|
+
they can't be found."""
|
|
520
|
+
words = _command_words(stmt)[:3]
|
|
521
|
+
pattern = r"\b" + r"\W+".join(map(re.escape, words)) + r"\b"
|
|
522
|
+
hit = re.compile(pattern, re.IGNORECASE).search(chunk, after)
|
|
523
|
+
if hit is None:
|
|
524
|
+
rows = chunk.split("\n")
|
|
525
|
+
first = next((i for i, row in enumerate(rows) if row.strip()), 0)
|
|
526
|
+
return start_line + first, after
|
|
527
|
+
return start_line + chunk.count("\n", 0, hit.start()), hit.end()
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
@contextlib.contextmanager
|
|
531
|
+
def quiet_sqlglot():
|
|
532
|
+
"""Hold sqlglot's logger at ERROR while checking. It warns 'contains
|
|
533
|
+
unsupported syntax' on stderr for every Command fallback, and the
|
|
534
|
+
checker's output must be only TrueQuery's. The level is restored
|
|
535
|
+
afterwards, so a host application's logging is left as it was."""
|
|
536
|
+
logger = logging.getLogger("sqlglot")
|
|
537
|
+
before = logger.level
|
|
538
|
+
if logger.getEffectiveLevel() < logging.ERROR:
|
|
539
|
+
logger.setLevel(logging.ERROR)
|
|
540
|
+
try:
|
|
541
|
+
yield
|
|
542
|
+
finally:
|
|
543
|
+
logger.setLevel(before)
|
|
544
|
+
|
|
545
|
+
|
|
404
546
|
def _parse_diagnostic(start_line, chunk, exc):
|
|
405
547
|
"""One clean agent-facing line + full detail for --json/--verbose.
|
|
406
548
|
|
|
@@ -474,6 +616,7 @@ def _active_checks(registry, settings, tiers, include_disabled):
|
|
|
474
616
|
INTDIV = "sql/integer-division-truncation"
|
|
475
617
|
|
|
476
618
|
|
|
619
|
+
@quiet_sqlglot()
|
|
477
620
|
def check_text(text, dialect=None, path="<input>", mode="build", registry=None,
|
|
478
621
|
include_disabled=False, tiers=None, settings=None):
|
|
479
622
|
"""Run enabled file-level checks. Returns {path, findings,
|
|
@@ -516,9 +659,21 @@ def check_text(text, dialect=None, path="<input>", mode="build", registry=None,
|
|
|
516
659
|
diagnostics.append(_parse_diagnostic(start_line + first, chunk,
|
|
517
660
|
exc))
|
|
518
661
|
continue
|
|
662
|
+
searched = 0
|
|
519
663
|
for stmt in stmts:
|
|
520
664
|
if stmt is None:
|
|
521
665
|
continue
|
|
666
|
+
detail = unread_detail(stmt)
|
|
667
|
+
if detail is not None:
|
|
668
|
+
# A query read only as an opaque Command: not checked,
|
|
669
|
+
# like any parse failure. The chunk's other statements
|
|
670
|
+
# still are.
|
|
671
|
+
line, searched = _command_line(chunk, stmt, start_line,
|
|
672
|
+
searched)
|
|
673
|
+
diagnostics.append({
|
|
674
|
+
"message": f"line {line}: could not parse (not checked)",
|
|
675
|
+
"detail": detail})
|
|
676
|
+
continue
|
|
522
677
|
loc = Locator(chunk, start_line)
|
|
523
678
|
for slug, check, record, setting in active:
|
|
524
679
|
for node, why, fix in check(stmt, loc, ctx):
|
|
@@ -377,7 +377,7 @@ def accidental_cross_join(stmt, loc, ctx):
|
|
|
377
377
|
if join.args.get("using"):
|
|
378
378
|
continue # JOIN ... USING names explicit keys
|
|
379
379
|
right_alias = _alias_key(join.this)
|
|
380
|
-
sel =
|
|
380
|
+
sel = _join_scope(join)
|
|
381
381
|
others = _from_keys(sel, join, right_alias) if sel is not None else set()
|
|
382
382
|
if _is_correlated(join.this, others, ctx.dialect):
|
|
383
383
|
continue # LATERAL / function over earlier columns: linked
|
|
@@ -445,8 +445,48 @@ def _qualifiers(node):
|
|
|
445
445
|
return {_ident_key(c.args.get("table")) for c in node.find_all(exp.Column)}
|
|
446
446
|
|
|
447
447
|
|
|
448
|
+
def _join_scope(join):
|
|
449
|
+
"""The query level a join belongs to: its SELECT, or the UPDATE /
|
|
450
|
+
DELETE whose FROM / USING holds it. sqlglot hangs Postgres
|
|
451
|
+
`UPDATE t ... FROM a JOIN b` and `DELETE FROM t USING a JOIN b`
|
|
452
|
+
joins on the FROM / USING table, with no SELECT around them."""
|
|
453
|
+
node = getattr(join, "parent", None)
|
|
454
|
+
while node is not None:
|
|
455
|
+
if isinstance(node, exp.Select):
|
|
456
|
+
return node
|
|
457
|
+
if isinstance(node, (exp.Update, exp.Delete)):
|
|
458
|
+
return node
|
|
459
|
+
node = getattr(node, "parent", None)
|
|
460
|
+
return None
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def _dml_from_keys(dml, join, this_alias):
|
|
464
|
+
"""Alias keys an UPDATE / DELETE join can link to: the target, the
|
|
465
|
+
FROM / USING items and their other joins."""
|
|
466
|
+
items = [dml.this]
|
|
467
|
+
sources = dml.args.get("from_") if isinstance(dml, exp.Update) else None
|
|
468
|
+
if sources is not None:
|
|
469
|
+
items.append(sources.this)
|
|
470
|
+
items.extend(sources.expressions or [])
|
|
471
|
+
items.extend(dml.args.get("using") or [])
|
|
472
|
+
others = set()
|
|
473
|
+
for item in items:
|
|
474
|
+
if item is None:
|
|
475
|
+
continue
|
|
476
|
+
name = _alias_key(item)
|
|
477
|
+
if name and name != this_alias:
|
|
478
|
+
others.add(name)
|
|
479
|
+
for other in item.args.get("joins") or []:
|
|
480
|
+
name = _alias_key(other.this) if other is not join else ""
|
|
481
|
+
if name and name != this_alias:
|
|
482
|
+
others.add(name)
|
|
483
|
+
return others
|
|
484
|
+
|
|
485
|
+
|
|
448
486
|
def _from_keys(sel, join, this_alias):
|
|
449
487
|
"""Alias keys of every top-level FROM item except this one."""
|
|
488
|
+
if isinstance(sel, (exp.Update, exp.Delete)):
|
|
489
|
+
return _dml_from_keys(sel, join, this_alias)
|
|
450
490
|
others = set()
|
|
451
491
|
frm = sel.args.get("from_")
|
|
452
492
|
if frm is not None and frm.this is not None:
|
|
@@ -465,7 +505,7 @@ def _from_keys(sel, join, this_alias):
|
|
|
465
505
|
def _joined_on_ast(join, this_alias):
|
|
466
506
|
"""True when some predicate links this table to another FROM table,
|
|
467
507
|
judged on column qualifiers — never on text substrings."""
|
|
468
|
-
sel =
|
|
508
|
+
sel = _join_scope(join)
|
|
469
509
|
if sel is None:
|
|
470
510
|
return False
|
|
471
511
|
others = _from_keys(sel, join, this_alias)
|
|
@@ -524,7 +564,7 @@ def _on_links_both_sides(join, right_alias):
|
|
|
524
564
|
(`ON key = t.key` can only resolve against the remaining FROM scope),
|
|
525
565
|
so requiring both qualifiers misfires on ordinary joins. `ON a.flag
|
|
526
566
|
= 1` still crosses: it never references the joined table at all."""
|
|
527
|
-
sel =
|
|
567
|
+
sel = _join_scope(join)
|
|
528
568
|
if sel is None or not right_alias:
|
|
529
569
|
return False
|
|
530
570
|
others = _from_keys(sel, join, right_alias)
|
|
@@ -984,6 +1024,8 @@ def distinct_dedup_bandaid(stmt, loc, ctx):
|
|
|
984
1024
|
def insert_explicit_column_list(stmt, loc, ctx):
|
|
985
1025
|
out = []
|
|
986
1026
|
for insert in stmt.find_all(exp.Insert):
|
|
1027
|
+
if insert.args.get("default"):
|
|
1028
|
+
continue # INSERT INTO t DEFAULT VALUES: no values, no order
|
|
987
1029
|
if isinstance(insert.this, exp.Table):
|
|
988
1030
|
out.append((insert,
|
|
989
1031
|
"INSERT without a column list breaks silently when columns are added or reordered",
|
|
@@ -1147,6 +1189,72 @@ def _qualify_filters(qualify):
|
|
|
1147
1189
|
for node in qualify.find_all(exp.EQ, exp.LT, exp.LTE))
|
|
1148
1190
|
|
|
1149
1191
|
|
|
1192
|
+
_ORDINALITY = "U:ordinality" # the column's name when none is declared
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
def _ordinality_names(item, stmt, depth=0):
|
|
1196
|
+
"""{(name, qualifier)} of WITH ORDINALITY numbers a FROM item exposes,
|
|
1197
|
+
unique per row of it. Declared name (`AS u(v, n)`, the last column)
|
|
1198
|
+
or the default `ordinality`. A CTE or subquery passes the column
|
|
1199
|
+
through when it reads that one source alone (no join to repeat it)
|
|
1200
|
+
and selects it by name."""
|
|
1201
|
+
if depth > 4 or item is None:
|
|
1202
|
+
return set()
|
|
1203
|
+
qual = _alias_key(item)
|
|
1204
|
+
inner = item.this if isinstance(item, exp.Lateral) else item
|
|
1205
|
+
if isinstance(inner, exp.Unnest):
|
|
1206
|
+
offset = inner.args.get("offset")
|
|
1207
|
+
if isinstance(offset, exp.Identifier):
|
|
1208
|
+
return {(_ident_key(offset), qual)}
|
|
1209
|
+
return {(_ORDINALITY, qual)} if offset is True else set()
|
|
1210
|
+
if item.args.get("ordinality"):
|
|
1211
|
+
alias = item.args.get("alias")
|
|
1212
|
+
cols = alias.args.get("columns") if alias is not None else None
|
|
1213
|
+
name = _ident_key(cols[-1]) if cols else _ORDINALITY
|
|
1214
|
+
return {(name, qual)}
|
|
1215
|
+
sel = None
|
|
1216
|
+
if isinstance(item, exp.Subquery):
|
|
1217
|
+
sel = item.this
|
|
1218
|
+
elif isinstance(item, exp.Table) and not item.args.get("db"):
|
|
1219
|
+
sel = _cte_select(stmt, _ident_key(item.this))
|
|
1220
|
+
if not isinstance(sel, exp.Select) or sel.args.get("joins"):
|
|
1221
|
+
return set()
|
|
1222
|
+
frm = sel.args.get("from_")
|
|
1223
|
+
source = _ordinality_names(frm.this if frm is not None else None, stmt,
|
|
1224
|
+
depth + 1)
|
|
1225
|
+
names = {name for name, _ in source}
|
|
1226
|
+
out = set()
|
|
1227
|
+
for proj in sel.expressions:
|
|
1228
|
+
col = proj.this if isinstance(proj, exp.Alias) else proj
|
|
1229
|
+
if isinstance(col, exp.Column) and _ident_key(col.this) in names:
|
|
1230
|
+
out.add((_ident_key(proj.args.get("alias"))
|
|
1231
|
+
if isinstance(proj, exp.Alias) else _ident_key(col.this),
|
|
1232
|
+
qual))
|
|
1233
|
+
return out
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
def _cte_select(stmt, name):
|
|
1237
|
+
for cte in stmt.find_all(exp.CTE):
|
|
1238
|
+
if _ident_key(cte.args.get("alias").this) == name:
|
|
1239
|
+
return cte.this
|
|
1240
|
+
return None
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
def _orders_by_ordinality(window, key):
|
|
1244
|
+
"""The single ORDER BY key is a WITH ORDINALITY number of the one
|
|
1245
|
+
source the window's SELECT reads: unique, so no ties to break."""
|
|
1246
|
+
col = key.this if isinstance(key, exp.Ordered) else key
|
|
1247
|
+
sel = _owning_select(window)
|
|
1248
|
+
if not isinstance(col, exp.Column) or sel is None or sel.args.get("joins"):
|
|
1249
|
+
return False
|
|
1250
|
+
frm = sel.args.get("from_")
|
|
1251
|
+
stmt = sel.root()
|
|
1252
|
+
names = _ordinality_names(frm.this if frm is not None else None, stmt)
|
|
1253
|
+
name = _ident_key(col.this)
|
|
1254
|
+
qual = _ident_key(col.args.get("table"))
|
|
1255
|
+
return any(name == n and (not qual or qual == q) for n, q in names)
|
|
1256
|
+
|
|
1257
|
+
|
|
1150
1258
|
def row_number_dedupe_tiebreaker(stmt, loc, ctx):
|
|
1151
1259
|
out = []
|
|
1152
1260
|
for window in stmt.find_all(exp.Window):
|
|
@@ -1162,7 +1270,8 @@ def row_number_dedupe_tiebreaker(stmt, loc, ctx):
|
|
|
1162
1270
|
"a unique tiebreaker"))
|
|
1163
1271
|
continue
|
|
1164
1272
|
keys = order.expressions if hasattr(order, "expressions") else []
|
|
1165
|
-
if len(keys) == 1 and _picks_one_row(stmt, window)
|
|
1273
|
+
if (len(keys) == 1 and _picks_one_row(stmt, window)
|
|
1274
|
+
and not _orders_by_ordinality(window, keys[0])):
|
|
1166
1275
|
out.append((window,
|
|
1167
1276
|
"ROW_NUMBER with a single ORDER BY key picks an arbitrary "
|
|
1168
1277
|
"winner on ties (uniqueness can't be verified from the file)",
|
|
@@ -15,6 +15,7 @@ from truequery import report as RP
|
|
|
15
15
|
from truequery import schema
|
|
16
16
|
from truequery import settings as S
|
|
17
17
|
from truequery import std_registry
|
|
18
|
+
from truequery.analyzers import sql as analyzer
|
|
18
19
|
from truequery.engine import ENGINE_VERSION, active_overrides, run
|
|
19
20
|
|
|
20
21
|
EXIT_CLEAN = 0
|
|
@@ -712,6 +713,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
712
713
|
return parser
|
|
713
714
|
|
|
714
715
|
|
|
716
|
+
@analyzer.quiet_sqlglot()
|
|
715
717
|
def main(argv: list[str] | None = None) -> int:
|
|
716
718
|
parser = build_parser()
|
|
717
719
|
args = parser.parse_args(argv)
|
|
@@ -374,6 +374,7 @@ def _original_offset(sql: str, cleaned: str, offset: int) -> int:
|
|
|
374
374
|
return o_start
|
|
375
375
|
|
|
376
376
|
|
|
377
|
+
@analyzer.quiet_sqlglot()
|
|
377
378
|
def check_python_source(text: str, path: str, dialect: str | None = None,
|
|
378
379
|
mode: str = "build", tiers=None, settings=None,
|
|
379
380
|
extraction=None):
|
|
@@ -434,6 +435,7 @@ def check_python_source(text: str, path: str, dialect: str | None = None,
|
|
|
434
435
|
return findings, extraction.fragments, spans
|
|
435
436
|
|
|
436
437
|
|
|
438
|
+
@analyzer.quiet_sqlglot()
|
|
437
439
|
def statement_spans(path: str, text: str, dialect: str | None) -> list:
|
|
438
440
|
"""Statement spans for ignores and baselines: per SQL statement in a
|
|
439
441
|
SQL file, per statement of each SQL fragment in a .py file."""
|
|
@@ -442,6 +444,7 @@ def statement_spans(path: str, text: str, dialect: str | None) -> list:
|
|
|
442
444
|
return _chunk_hashes(text, dialect)
|
|
443
445
|
|
|
444
446
|
|
|
447
|
+
@analyzer.quiet_sqlglot()
|
|
445
448
|
def check_file(path: str, dialect: str | None = None,
|
|
446
449
|
mode: str = "build", tiers=None,
|
|
447
450
|
settings=None, text: str | None = None
|
|
@@ -521,6 +524,7 @@ def _apply_ignores(result: FileResult, findings: list, spans, ignores) -> None:
|
|
|
521
524
|
result.findings.sort(key=Finding.sort_key)
|
|
522
525
|
|
|
523
526
|
|
|
527
|
+
@analyzer.quiet_sqlglot()
|
|
524
528
|
def run(paths: list[str], root: str, dialect: str | None = None,
|
|
525
529
|
mode: str | None = None, tiers=None, settings=None,
|
|
526
530
|
config: dict | None = None) -> list[FileResult]:
|
|
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
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/adhoc-limit-required.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/aggregate-before-export.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/consumer-reads-marts.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/dashboard-query-budget.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/dashboard-refresh-schedule.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/deterministic-export-order.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/explicit-timezone-consumers.yaml
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
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/reverse-etl-idempotent-keys.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/reverse-etl-pii-consent.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/consume/reverse-etl-schema-contract.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/accuracy-proxy-or-unmeasurable.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/audits-blocking-every-run.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/checks-versioned-with-code.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/completeness-fill-rate-thresholds.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/completeness-table-not-empty.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/consistency-no-orphan-keys.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/unenforced-constraints-are-tested.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/uniqueness-composite-grain.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/uniqueness-key-no-duplicates.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/validity-allowed-value-sets.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/validity-enforce-model-contracts.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/dq/validity-range-format-type-rules.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/audit-columns-or-snapshots.yaml
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
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/lineage-from-declared-sources.yaml
RENAMED
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/mesh-public-contracts-only.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{truequery-0.1.2 → truequery-0.1.3}/src/truequery/standard/gov/pii-classification-declared.yaml
RENAMED
|
File without changes
|