truequery 0.1.3__tar.gz → 0.1.4__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.3 → truequery-0.1.4}/PKG-INFO +1 -1
- {truequery-0.1.3 → truequery-0.1.4}/pyproject.toml +1 -1
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/__init__.py +1 -1
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/analyzers/sql.py +520 -50
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/cli.py +9 -5
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/engine.py +12 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/hook.py +98 -29
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/project.py +1 -1
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/report.py +13 -1
- {truequery-0.1.3 → truequery-0.1.4}/.gitignore +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/LICENSE +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/NOTICE +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/analyzers/__init__.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/analyzers/project_checks.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/checks/__init__.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/checks/sql.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/extractors/__init__.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/extractors/python_sql.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/keylookup.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/models.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/registry_impl.json +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/schema.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/settings.py +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/adhoc-limit-required.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/aggregate-before-export.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/consumer-cost-guard.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/consumer-reads-marts.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/dashboard-query-budget.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/dashboard-refresh-schedule.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/deterministic-export-order.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explicit-timezone-consumers.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-answer-carries-reproducible-query.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-caveats-and-unchecked-stated.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-day-boundaries-and-partial-periods.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-experiment-readout-follows-plan.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-freshness-and-coverage-checked.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-inspect-distributions-and-examples.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-join-row-count-checks.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-null-aware-negative-filters.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-question-metric-grain-stated.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-rates-not-counts-across-segments.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-reconcile-to-known-total.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/explore-reuse-governed-metric.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/export-row-cap.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/freshness-displayed.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/no-deep-offset.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/parameterized-dashboard-filters.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/reverse-etl-idempotent-keys.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/reverse-etl-pii-consent.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/consume/reverse-etl-schema-contract.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/accuracy-proxy-or-unmeasurable.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/audits-blocking-every-run.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/checks-versioned-with-code.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/completeness-declare-missing-sentinels.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/completeness-fill-rate-thresholds.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/completeness-not-null-required-columns.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/completeness-table-not-empty.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/consistency-cross-column-row-rules.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/consistency-no-orphan-keys.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/consistency-paired-aggregate-reconciliation.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/schema-conformance-checked-on-read.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/unenforced-constraints-are-tested.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/uniqueness-composite-grain.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/uniqueness-key-no-duplicates.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/unit-tests-with-fixtures.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/validity-allowed-value-sets.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/validity-enforce-model-contracts.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/dq/validity-range-format-type-rules.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/audit-columns-or-snapshots.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/column-grants-for-pii.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/declared-model-owner.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/description-coverage-for-shared-models.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/erasure-path-documented.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/exposures-registered.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/group-private-access.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/least-privilege-grants.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/lineage-from-declared-sources.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/mesh-public-contracts-only.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/no-bypassrls-roles.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/no-public-privileges.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/no-raw-pii-in-seeds.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/pii-classification-declared.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/production-pii-not-in-dev.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/redacting-views-for-pii.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/retention-declared.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/gov/row-policy-for-sensitive-tables.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/cap-intake-cost-and-volume.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/cdc-replica-identity-required.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/checkpoint-streaming-intake.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/choose-batch-vs-streaming-deliberately.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/declare-source-freshness.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/dedupe-on-natural-key-before-append.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/handle-schema-drift-explicitly.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/idempotent-batch-loads.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/isolate-source-failures.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/landing-rebuildable-from-source.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/monitor-cdc-lag-and-slots.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/pin-connector-and-schema-versions.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/pin-file-format-options.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/propagate-deletes-explicitly.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/quarantine-invalid-rows-at-intake.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/raw-landing-append-only.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/reconcile-row-counts-per-load.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/record-file-lineage-at-intake.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/reference-sources-not-raw-tables.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/require-completeness-marker.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/scan-pii-at-landing.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/seeds-small-static-only.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/test-intake-against-fixtures.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ingest/watermark-and-late-data-policy.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/dbt-contract-enforced.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/delete-handling-incremental.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/explicit-column-lists.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/full-refresh-parity.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/grain-preserved-joins.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/idempotent-reexec.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/incremental-lookback-window.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/incremental-watermark-filter.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/jinja-macro-determinism.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/jinja-no-nested-curlies.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/materialization-choice.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/merge-source-deduped.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/microbatch-event-time.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/null-join-keys-excluded.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/snapshot-scd2-validity.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/snapshot-strategy-choice.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/staging-no-business-logic.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/surrogate-keys-stable.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/model/unique-key-merge-key.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/breaking-change-categorization.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/ci-pr-checks-required.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/ci-slim-builds-only-changed.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/cost-estimate-before-run.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/cost-guardrail-confidence-levels.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/dev-environment-expiry.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/disposable-dev-environments.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/drift-detection-history-first.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/full-refresh-approval.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/model-versioning-breaking-changes.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/plan-preview-before-apply.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/post-deploy-data-validation.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/pre-destructive-snapshot.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/prod-credentials-isolation.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/run-artifact-retention.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/ops/staged-upgrades-with-backup.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/concurrency-pools-and-limits.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/dag-ci-parse-and-unit-tests.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/data-aware-scheduling-over-polling.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/declared-asset-lineage.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/deferrable-sensors-with-timeout.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/explicit-catchup-policy.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/explicit-schedule-timezone.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/failure-alert-routing.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/idempotent-backfill-windowing.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/idempotent-retries-with-limits.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/light-dag-parse-no-heavy-top-level.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/no-circular-dependencies.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/partitioned-assets-windowing.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/sla-deadline-alerts.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/task-atomicity-no-partial-writes.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/orch/task-timeout-execution-limit.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/airflow-isolate-task-dependencies.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/dagster-asset-declared-dependencies.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/dagster-io-manager-not-manual-io.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/dagster-resources-for-external-clients.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/dbt-python-model-contract.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/deterministic-model-outputs.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/hook-adapter-connection-lifecycle.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/idempotent-task-logic.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/no-n-plus-one-queries-in-loops.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/pandas-filter-before-collect.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/pandas-no-chained-assignment.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/pandas-no-row-loop-mutations.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/pin-pipeline-dependencies.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/sqlmesh-audit-python-outputs.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/py/sqlmesh-python-model-execution-context.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/aggregation-type-matches-additivity.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/conversion-metrics-window-bounds.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/count-distinct-uses-entity-key.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/cumulative-metrics-time-spine.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/derived-metrics-compose-from-governed.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/description-and-ownership-per-metric.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/dimension-naming-conventions.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/entity-primary-key-declared.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/join-paths-declared-via-entities.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/metric-filters-declared-not-hidden.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/metric-grain-declaration.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/metric-smoke-test-on-change.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/no-fanout-double-counting.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/no-metric-defined-off-staging.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/null-handling-in-aggregations.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/percentile-metrics-use-approximate.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/ratio-metrics-divide-after-aggregation.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/saved-query-canonical-slices.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/semantic-model-validates.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/single-governed-metric-definition.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/time-dimension-standardized.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sem/unit-consistency.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/accidental-cross-join.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/average-of-ratios.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/between-date-on-timestamp.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/case-without-else-in-aggregate.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/count-star-after-left-join.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/distinct-dedup-bandaid.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/explore-limit-is-not-a-sample.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/explore-profile-filter-columns.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/fanout-join-pre-aggregation.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/group-by-bare-column.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/insert-explicit-column-list.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/integer-division-truncation.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/keyset-pagination.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/left-join-null-rejecting-where.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/limit-requires-order-by.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/natural-join-explicit-keys.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/negative-filter-drops-nulls.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/nondeterministic-merge-keys.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/not-in-nullable-subquery.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/null-equality-comparison.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/random-sampling-no-sort.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/row-number-dedupe-tiebreaker.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/sargable-filter-bare-column.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/set-operation-column-position.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/unguarded-update-delete.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/sql/union-all-default.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/README.md +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/cluster-on-frequent-filters-joins.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/compact-small-files-optimize.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/declare-not-null-check-constraints.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/declare-sort-order-for-range-queries.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/enable-change-feed-for-incremental-consumers.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/evolve-partitions-by-metadata-not-rewrite.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/explicit-physical-types-no-implicit-casts.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/full-refresh-by-replace-not-delete-insert.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/incremental-watermark-partition-alignment.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/no-high-cardinality-partition-column.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/partition-expiration-retention-policy.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/partition-on-filter-column.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/partition-predicate-required.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/prefer-auto-liquid-clustering-over-manual-tune.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/rewrite-manifests-and-stats-periodically.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/single-open-format-per-medallion-layer.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/time-travel-retention-explicit.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/use-transient-temporary-for-ephemeral.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/src/truequery/standard/store/vacuum-expire-snapshots-with-retention-floor.yaml +0 -0
- {truequery-0.1.3 → truequery-0.1.4}/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.4
|
|
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.4"
|
|
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"
|
|
@@ -193,7 +193,25 @@ def strip_jinja(text):
|
|
|
193
193
|
return "".join(out)
|
|
194
194
|
|
|
195
195
|
|
|
196
|
+
_DOLLAR_TAG = re.compile(r"\$(?:[A-Za-z_][A-Za-z_0-9]*)?\$")
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _dollar_end(text, i):
|
|
200
|
+
"""End of the dollar-quoted string ($$…$$ or $tag$…$tag$) that opens
|
|
201
|
+
at text[i], or None: not an opening tag (a `$1` parameter, a `$`
|
|
202
|
+
inside a name) or never closed."""
|
|
203
|
+
if i and (text[i - 1].isalnum() or text[i - 1] in "_$"):
|
|
204
|
+
return None
|
|
205
|
+
tag = _DOLLAR_TAG.match(text, i)
|
|
206
|
+
if tag is None:
|
|
207
|
+
return None
|
|
208
|
+
close = text.find(tag.group(0), tag.end())
|
|
209
|
+
return None if close == -1 else close + len(tag.group(0))
|
|
210
|
+
|
|
211
|
+
|
|
196
212
|
def strip_comments(text, dialect):
|
|
213
|
+
"""Blank comments, keeping every newline and the text's length.
|
|
214
|
+
Quoted strings and dollar-quoted bodies are kept as they are."""
|
|
197
215
|
out, i, n = [], 0, len(text)
|
|
198
216
|
squote = False
|
|
199
217
|
while i < n:
|
|
@@ -226,6 +244,9 @@ def strip_comments(text, dialect):
|
|
|
226
244
|
for c in text[i:end]:
|
|
227
245
|
out.append("\n" if c == "\n" else " ")
|
|
228
246
|
i = end
|
|
247
|
+
elif ch == "$" and (end := _dollar_end(text, i)) is not None:
|
|
248
|
+
out.append(text[i:end]) # a function body: checked on its own
|
|
249
|
+
i = end
|
|
229
250
|
else:
|
|
230
251
|
out.append(ch)
|
|
231
252
|
i += 1
|
|
@@ -233,23 +254,30 @@ def strip_comments(text, dialect):
|
|
|
233
254
|
|
|
234
255
|
|
|
235
256
|
def split_statements(cleaned):
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
257
|
+
"""(text, start line) per statement: split at `;` outside quotes,
|
|
258
|
+
brackets and dollar-quoted bodies. The parts are contiguous."""
|
|
259
|
+
parts, depth, start, line = [], 0, 1, 1
|
|
260
|
+
squote, i, cut, n = False, 0, 0, len(cleaned)
|
|
261
|
+
while i < n:
|
|
262
|
+
ch = cleaned[i]
|
|
239
263
|
if ch == "'":
|
|
240
264
|
squote = not squote
|
|
241
|
-
|
|
265
|
+
elif not squote:
|
|
266
|
+
if ch == "$" and (end := _dollar_end(cleaned, i)) is not None:
|
|
267
|
+
line += cleaned.count("\n", i, end)
|
|
268
|
+
i = end
|
|
269
|
+
continue
|
|
242
270
|
if ch in "([":
|
|
243
271
|
depth += 1
|
|
244
272
|
elif ch in ")]":
|
|
245
273
|
depth -= 1
|
|
246
|
-
|
|
274
|
+
elif ch == ";" and depth == 0:
|
|
275
|
+
parts.append((cleaned[cut:i + 1], start))
|
|
276
|
+
cut, start = i + 1, line
|
|
247
277
|
if ch == "\n":
|
|
248
278
|
line += 1
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
cur, start = [], line
|
|
252
|
-
tail = "".join(cur)
|
|
279
|
+
i += 1
|
|
280
|
+
tail = cleaned[cut:]
|
|
253
281
|
if tail.strip() and tail.strip().strip(";"):
|
|
254
282
|
parts.append((tail, start))
|
|
255
283
|
return parts
|
|
@@ -295,9 +323,13 @@ def _usable_needle(needle, compact):
|
|
|
295
323
|
|
|
296
324
|
|
|
297
325
|
class Locator:
|
|
298
|
-
def __init__(self, stmt_text, start_line):
|
|
326
|
+
def __init__(self, stmt_text, start_line, origin=None):
|
|
299
327
|
self.text = stmt_text
|
|
300
328
|
self.start_line = start_line
|
|
329
|
+
# (chunk, pos) when stmt_text is a query inside a wrapper or a
|
|
330
|
+
# function body: pos[i] is the chunk offset of stmt_text[i], and
|
|
331
|
+
# lines and columns are the chunk's (start_line is its first).
|
|
332
|
+
self.origin = origin
|
|
301
333
|
# Rules append their slug here when a declared-key lookup
|
|
302
334
|
# suppresses a firing; check_text reports them.
|
|
303
335
|
self.suppressed = []
|
|
@@ -332,10 +364,14 @@ class Locator:
|
|
|
332
364
|
nth = self.used.get((rule, None), 0)
|
|
333
365
|
off = self._locate_anchor(rule, nth)
|
|
334
366
|
self.used[(rule, None)] = nth + 1
|
|
367
|
+
text = self.text
|
|
368
|
+
if self.origin is not None:
|
|
369
|
+
text, pos = self.origin
|
|
370
|
+
off = pos[min(off, len(pos) - 1)]
|
|
335
371
|
# Offset inside the statement text, for callers that map
|
|
336
372
|
# positions back to another file (SQL inside Python).
|
|
337
373
|
self.last_offset = off
|
|
338
|
-
pre =
|
|
374
|
+
pre = text[:off]
|
|
339
375
|
return (self.start_line + pre.count("\n"),
|
|
340
376
|
off - (pre.rfind("\n") + 1) + 1)
|
|
341
377
|
|
|
@@ -513,18 +549,464 @@ def unread_detail(stmt):
|
|
|
513
549
|
"only as an opaque command, so no check looked inside it")
|
|
514
550
|
|
|
515
551
|
|
|
516
|
-
def
|
|
517
|
-
"""(
|
|
518
|
-
`after
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
552
|
+
def _command_span(text, stmt, after):
|
|
553
|
+
"""(start, end) of a Command statement in text, searching from
|
|
554
|
+
`after`. sqlglot keeps the Command's text verbatim (its head, then
|
|
555
|
+
the rest), so it is found exactly; None when it isn't."""
|
|
556
|
+
head = str(stmt.this or "")
|
|
557
|
+
rest = stmt.expression
|
|
558
|
+
if isinstance(rest, _exp.Literal):
|
|
559
|
+
rest = rest.name
|
|
560
|
+
elif isinstance(rest, _exp.Expression):
|
|
561
|
+
return None
|
|
562
|
+
rest = str(rest or "").strip()
|
|
563
|
+
if not head:
|
|
564
|
+
return None
|
|
565
|
+
for hit in re.finditer(r"(?<![\w$])" + re.escape(head) + r"(?![\w$])",
|
|
566
|
+
text[after:], re.IGNORECASE):
|
|
567
|
+
start = after + hit.start()
|
|
568
|
+
i = after + hit.end()
|
|
569
|
+
while i < len(text) and text[i].isspace():
|
|
570
|
+
i += 1
|
|
571
|
+
if text.startswith(rest, i):
|
|
572
|
+
return start, i + len(rest)
|
|
573
|
+
return None
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
# -- queries inside wrappers and function bodies ------------------------------
|
|
577
|
+
# A wrapper holds a whole query: EXPLAIN [ANALYZE] [VERBOSE] [(options)]
|
|
578
|
+
# <query>, PREPARE name [(types)] AS <query>, DECLARE name … CURSOR …
|
|
579
|
+
# FOR <query>, CREATE TABLE / [MATERIALIZED] VIEW … AS <query>. sqlglot
|
|
580
|
+
# reads these only as a Command; the query inside is found in the text,
|
|
581
|
+
# parsed and checked like any other. A wrapper whose query isn't found,
|
|
582
|
+
# or doesn't parse, stays not checked (see unread_detail).
|
|
583
|
+
_EXPLAIN_OPTIONS = frozenset({
|
|
584
|
+
"ANALYZE", "ANALYSE", "VERBOSE", # Postgres, MySQL, DuckDB
|
|
585
|
+
"QUERY", "PLAN", "FOR", # SQLite QUERY PLAN, Oracle PLAN FOR
|
|
586
|
+
"EXTENDED", "PARTITIONS", "FORMAT", # MySQL (FORMAT=JSON)
|
|
587
|
+
"JSON", "TEXT", "TREE", "TRADITIONAL", "XML", "YAML",
|
|
588
|
+
"USING", "TABULAR", # Snowflake EXPLAIN USING TEXT
|
|
589
|
+
"FORMATTED", "COST", "CODEGEN", "LOGICAL", # Spark
|
|
590
|
+
})
|
|
591
|
+
# Words a wrapped statement starts with. PREPARE / DECLARE / CREATE …
|
|
592
|
+
# AS also accept a parenthesised query.
|
|
593
|
+
_INNER_HEADS = frozenset({
|
|
594
|
+
"SELECT", "WITH", "VALUES", "TABLE", "FROM", "INSERT", "UPDATE",
|
|
595
|
+
"DELETE", "MERGE", "REPLACE", "UPSERT",
|
|
596
|
+
"CREATE", # EXPLAIN CREATE TABLE … AS
|
|
597
|
+
"DECLARE", # EXPLAIN DECLARE … CURSOR
|
|
598
|
+
"EXECUTE", # EXPLAIN EXECUTE p, CREATE TABLE t AS EXECUTE p
|
|
599
|
+
})
|
|
600
|
+
_WRAPPING_OBJECTS = frozenset({"TABLE", "VIEW"})
|
|
601
|
+
_NO_DATA = re.compile(r"\s+WITH\s+(?:NO\s+)?DATA\s*$", re.IGNORECASE)
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def _top_words(text, lo, hi):
|
|
605
|
+
"""(WORD, start, end) for each word of text[lo:hi] outside brackets,
|
|
606
|
+
quoted strings, quoted names and dollar-quoted bodies."""
|
|
607
|
+
depth, i = 0, lo
|
|
608
|
+
while i < hi:
|
|
609
|
+
ch = text[i]
|
|
610
|
+
if ch in "'\"`":
|
|
611
|
+
j = text.find(ch, i + 1)
|
|
612
|
+
while ch == "'" and j != -1 and text.startswith("''", j):
|
|
613
|
+
j = text.find(ch, j + 2)
|
|
614
|
+
i = hi if j == -1 else j + 1
|
|
615
|
+
continue
|
|
616
|
+
if ch == "$" and (end := _dollar_end(text, i)) is not None:
|
|
617
|
+
i = end
|
|
618
|
+
continue
|
|
619
|
+
if ch in "([":
|
|
620
|
+
depth += 1
|
|
621
|
+
elif ch in ")]":
|
|
622
|
+
depth -= 1
|
|
623
|
+
elif depth == 0 and (ch.isalpha() or ch == "_") and not (
|
|
624
|
+
i > lo and (text[i - 1].isalnum() or text[i - 1] in "_$")):
|
|
625
|
+
word = _WORD.match(text, i)
|
|
626
|
+
yield word.group(0).upper(), word.start(), word.end()
|
|
627
|
+
i = word.end()
|
|
628
|
+
continue
|
|
629
|
+
i += 1
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
def _query_after(text, at, hi):
|
|
633
|
+
"""Start of the statement that begins at or after `at`, when it
|
|
634
|
+
begins with one of _INNER_HEADS, in brackets or not; None otherwise
|
|
635
|
+
(`AS ({placeholder})` is no query to check)."""
|
|
636
|
+
while at < hi and text[at].isspace():
|
|
637
|
+
at += 1
|
|
638
|
+
first = at
|
|
639
|
+
while at < hi and (text[at].isspace() or text[at] == "("):
|
|
640
|
+
at += 1
|
|
641
|
+
word = _WORD.match(text, at)
|
|
642
|
+
return first if word and word.group(0).upper() in _INNER_HEADS else None
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
def _inner_query(text, start, end):
|
|
646
|
+
"""(start, end) of the query inside a wrapper Command spanning
|
|
647
|
+
text[start:end], or None when it isn't one of the forms above."""
|
|
648
|
+
words = list(_top_words(text, start, end))
|
|
649
|
+
if not words:
|
|
650
|
+
return None
|
|
651
|
+
head = words[0][0]
|
|
652
|
+
begin = None
|
|
653
|
+
if head == "EXPLAIN":
|
|
654
|
+
for word, at, _ in words[1:]:
|
|
655
|
+
if word in _INNER_HEADS:
|
|
656
|
+
begin = at
|
|
657
|
+
break
|
|
658
|
+
if word not in _EXPLAIN_OPTIONS:
|
|
659
|
+
return None
|
|
660
|
+
elif head == "PREPARE":
|
|
661
|
+
after_as = next((e for w, _, e in words[1:] if w == "AS"), None)
|
|
662
|
+
if after_as is not None:
|
|
663
|
+
begin = _query_after(text, after_as, end)
|
|
664
|
+
elif head == "DECLARE":
|
|
665
|
+
names = [w for w, _, _ in words]
|
|
666
|
+
if "CURSOR" in names:
|
|
667
|
+
cursor = names.index("CURSOR")
|
|
668
|
+
after_for = next((e for w, _, e in words[cursor + 1:]
|
|
669
|
+
if w == "FOR"), None)
|
|
670
|
+
if after_for is not None:
|
|
671
|
+
begin = _query_after(text, after_for, end)
|
|
672
|
+
elif head == "CREATE":
|
|
673
|
+
obj = next((w for w, _, _ in words[1:]
|
|
674
|
+
if w not in _OBJECT_MODIFIERS), "")
|
|
675
|
+
after_as = next((e for w, _, e in words[1:] if w == "AS"), None)
|
|
676
|
+
if obj in _WRAPPING_OBJECTS and after_as is not None:
|
|
677
|
+
begin = _query_after(text, after_as, end)
|
|
678
|
+
tail = _NO_DATA.search(text, begin or start, end)
|
|
679
|
+
if tail is not None:
|
|
680
|
+
end = tail.start()
|
|
681
|
+
if begin is None or begin >= end:
|
|
682
|
+
return None
|
|
683
|
+
return begin, end
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
# Function and procedure bodies. A body in plain SQL (LANGUAGE sql, or no
|
|
687
|
+
# language) is parsed as statements and checked; a procedural body is
|
|
688
|
+
# not checked, and says so; a body in another language (python,
|
|
689
|
+
# javascript, c, …) holds no SQL, so it is left as it was.
|
|
690
|
+
_PROCEDURAL_LANGUAGES = {
|
|
691
|
+
"plpgsql": "PL/pgSQL", "plsql": "PL/SQL", "tsql": "T-SQL",
|
|
692
|
+
"sqlscript": "SQLScript", "spl": "SPL",
|
|
693
|
+
}
|
|
694
|
+
_SQL_LANGUAGES = frozenset({"sql", ""})
|
|
695
|
+
_ROUTINES = frozenset({"FUNCTION", "PROCEDURE"})
|
|
696
|
+
_BLOCK_HEAD = re.compile(r"\s*(BEGIN|DECLARE)\b(\s+ATOMIC\b)?", re.IGNORECASE)
|
|
697
|
+
_LANGUAGE = re.compile(r"\s*'?([A-Za-z_][A-Za-z_0-9]*)'?")
|
|
698
|
+
PROCEDURAL = "procedural code in"
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
def _block_name(dialect):
|
|
702
|
+
if dialect in ("snowflake",):
|
|
703
|
+
return "Snowflake Scripting"
|
|
704
|
+
if dialect in ("tsql", "fabric"):
|
|
705
|
+
return "T-SQL"
|
|
706
|
+
return "a BEGIN … END block"
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
def _string_bodies(text, lo, hi):
|
|
710
|
+
"""(content start, content end, quoted) for each string after a
|
|
711
|
+
top-level AS in text[lo:hi]: `AS $tag$…$tag$` or `AS '…'`."""
|
|
712
|
+
for word, _, after in _top_words(text, lo, hi):
|
|
713
|
+
if word != "AS":
|
|
714
|
+
continue
|
|
715
|
+
at = after
|
|
716
|
+
while at < hi and text[at].isspace():
|
|
717
|
+
at += 1
|
|
718
|
+
if text.startswith("$", at) and (end := _dollar_end(text, at)):
|
|
719
|
+
tag = _DOLLAR_TAG.match(text, at).group(0)
|
|
720
|
+
yield at + len(tag), end - len(tag), False
|
|
721
|
+
elif text.startswith("'", at):
|
|
722
|
+
j = text.find("'", at + 1)
|
|
723
|
+
while j != -1 and text.startswith("''", j):
|
|
724
|
+
j = text.find("'", j + 2)
|
|
725
|
+
if j != -1:
|
|
726
|
+
yield at + 1, j, True
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
def _language_in(text, lo, hi):
|
|
730
|
+
"""The LANGUAGE named in text[lo:hi], lowercased; "" when none."""
|
|
731
|
+
for word, _, after in _top_words(text, lo, hi):
|
|
732
|
+
if word == "LANGUAGE":
|
|
733
|
+
name = _LANGUAGE.match(text, after)
|
|
734
|
+
return name.group(1).lower() if name else ""
|
|
735
|
+
return ""
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
def _unquote(raw):
|
|
739
|
+
"""A single-quoted body's text with `''` read as `'`, and for each of
|
|
740
|
+
its characters (plus the end) the offset in raw."""
|
|
741
|
+
out, idx, i = [], [], 0
|
|
742
|
+
while i < len(raw):
|
|
743
|
+
out.append(raw[i])
|
|
744
|
+
idx.append(i)
|
|
745
|
+
i += 2 if raw.startswith("''", i) else 1
|
|
746
|
+
idx.append(len(raw))
|
|
747
|
+
return "".join(out), idx
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
def _is_block(text, at=0):
|
|
751
|
+
"""A procedural block starts at text[at]: BEGIN … END, or DECLARE …
|
|
752
|
+
BEGIN … END (Snowflake Scripting). Not BEGIN ATOMIC (a SQL-standard
|
|
753
|
+
body of plain statements), and not a lone DECLARE c CURSOR FOR …,
|
|
754
|
+
which is a SQL statement."""
|
|
755
|
+
head = _BLOCK_HEAD.match(text, at)
|
|
756
|
+
if head is None or head.group(2):
|
|
757
|
+
return False
|
|
758
|
+
if head.group(1).upper() == "BEGIN":
|
|
759
|
+
return True
|
|
760
|
+
return re.search(r"\bBEGIN\b", text[head.end():], re.IGNORECASE) \
|
|
761
|
+
is not None
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
def _routine_body(stmt):
|
|
765
|
+
"""For a CREATE FUNCTION / PROCEDURE whose body sqlglot keeps as
|
|
766
|
+
text: (body text, language). (None, language) for a BEGIN … END
|
|
767
|
+
block sqlglot parsed into the tree (T-SQL, or a SQL-standard BEGIN
|
|
768
|
+
ATOMIC), None when the body is otherwise part of the tree (BigQuery,
|
|
769
|
+
a SQL `RETURN expr`) or there is none."""
|
|
770
|
+
if not isinstance(stmt, _exp.Create) or str(
|
|
771
|
+
stmt.args.get("kind") or "").upper() not in _ROUTINES:
|
|
772
|
+
return None
|
|
773
|
+
body = stmt.expression
|
|
774
|
+
props = stmt.args.get("properties")
|
|
775
|
+
lang = next((p.name.lower() for p in (props.expressions if props else [])
|
|
776
|
+
if isinstance(p, _exp.LanguageProperty)), "")
|
|
777
|
+
if isinstance(body, _exp.Block) and stmt.args.get("begin"):
|
|
778
|
+
return None, lang
|
|
779
|
+
if isinstance(body, _exp.Block) and len(body.expressions) == 1 \
|
|
780
|
+
and isinstance(body.expressions[0], _exp.RawString):
|
|
781
|
+
body = body.expressions[0]
|
|
782
|
+
if isinstance(body, (_exp.Heredoc, _exp.RawString)) or (
|
|
783
|
+
isinstance(body, _exp.Literal) and body.is_string):
|
|
784
|
+
return body.name, lang
|
|
785
|
+
return None
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
class _Pass:
|
|
789
|
+
"""The checks over one chunk's statements, and over the queries
|
|
790
|
+
inside its wrappers and SQL function bodies. A piece of text being
|
|
791
|
+
checked has a `pos` map (pos[i] = chunk offset of text[i]); None
|
|
792
|
+
for the chunk itself."""
|
|
793
|
+
|
|
794
|
+
def __init__(self, active, ctx, path, mode, dialect):
|
|
795
|
+
self.active, self.ctx, self.path, self.mode = active, ctx, path, mode
|
|
796
|
+
self.dialect = dialect
|
|
797
|
+
self.findings, self.diagnostics, self.key_lookups = [], [], []
|
|
798
|
+
|
|
799
|
+
def chunk(self, chunk, start_line, base, stmts):
|
|
800
|
+
self.text, self.start_line, self.base = chunk, start_line, base
|
|
801
|
+
self._statements(stmts, chunk, None)
|
|
802
|
+
|
|
803
|
+
def wrapped_chunk(self, chunk, start_line, base):
|
|
804
|
+
"""A wrapper the dialect's parser rejects outright instead of
|
|
805
|
+
keeping it as a Command (under auto, `DECLARE … CURSOR` raises):
|
|
806
|
+
True when the query inside is found, parses and was checked."""
|
|
807
|
+
self.text, self.start_line, self.base = chunk, start_line, base
|
|
808
|
+
lead = len(chunk) - len(chunk.lstrip())
|
|
809
|
+
inner = _inner_query(chunk, lead, len(chunk))
|
|
810
|
+
return inner is not None and \
|
|
811
|
+
self._parse_piece(chunk, None, *inner) is None
|
|
812
|
+
|
|
813
|
+
# -- positions --
|
|
814
|
+
def _off(self, pos, i):
|
|
815
|
+
return i if pos is None else pos[min(i, len(pos) - 1)]
|
|
816
|
+
|
|
817
|
+
def _line(self, off):
|
|
818
|
+
return self.start_line + self.text.count("\n", 0, off)
|
|
819
|
+
|
|
820
|
+
def _first_line(self, text, pos):
|
|
821
|
+
lead = len(text) - len(text.lstrip())
|
|
822
|
+
return self._line(self._off(pos, lead))
|
|
823
|
+
|
|
824
|
+
def _sub(self, pos, lo, hi, idx=None):
|
|
825
|
+
"""pos map for text[lo:hi] (decoded through idx when given)."""
|
|
826
|
+
rel = idx if idx is not None else range(hi - lo + 1)
|
|
827
|
+
return [self._off(pos, lo + k) for k in rel]
|
|
828
|
+
|
|
829
|
+
def _diagnose(self, line, detail, what="could not parse"):
|
|
830
|
+
self.diagnostics.append({
|
|
831
|
+
"message": f"line {line}: {what} (not checked)",
|
|
832
|
+
"detail": detail})
|
|
833
|
+
|
|
834
|
+
# -- statements --
|
|
835
|
+
def _statements(self, stmts, text, pos):
|
|
836
|
+
searched = 0
|
|
837
|
+
for stmt in stmts:
|
|
838
|
+
if stmt is None:
|
|
839
|
+
continue
|
|
840
|
+
if isinstance(stmt, _exp.Command):
|
|
841
|
+
searched = self._command(stmt, text, pos, searched)
|
|
842
|
+
continue
|
|
843
|
+
body = _routine_body(stmt)
|
|
844
|
+
if body is not None:
|
|
845
|
+
searched = self._routine(stmt, body, text, pos, searched)
|
|
846
|
+
continue
|
|
847
|
+
self._check(stmt, text, pos)
|
|
848
|
+
|
|
849
|
+
def _parse_piece(self, text, pos, lo, hi):
|
|
850
|
+
"""Parse text[lo:hi] and check it. The parse error when it
|
|
851
|
+
doesn't parse (nothing checked), else None."""
|
|
852
|
+
piece = text[lo:hi]
|
|
853
|
+
try:
|
|
854
|
+
stmts = sqlglot.parse(piece, read=self.dialect or None)
|
|
855
|
+
except Exception as exc: # noqa: BLE001 - any parse error
|
|
856
|
+
return exc
|
|
857
|
+
self._statements(stmts, piece, self._sub(pos, lo, hi))
|
|
858
|
+
return None
|
|
859
|
+
|
|
860
|
+
def _command(self, stmt, text, pos, searched):
|
|
861
|
+
if not command_holds_query(stmt):
|
|
862
|
+
return searched
|
|
863
|
+
span = _command_span(text, stmt, searched)
|
|
864
|
+
if span is None:
|
|
865
|
+
self._diagnose(self._first_line(text[searched:], self._sub(
|
|
866
|
+
pos, searched, len(text))), unread_detail(stmt))
|
|
867
|
+
return searched
|
|
868
|
+
start, end = span
|
|
869
|
+
line = self._line(self._off(pos, start))
|
|
870
|
+
words = _command_words(stmt)
|
|
871
|
+
if words[0] == "DO":
|
|
872
|
+
lang = _language_in(text, start, end) or "plpgsql"
|
|
873
|
+
if lang in _PROCEDURAL_LANGUAGES:
|
|
874
|
+
body = next(((at, e) for at in range(start, end)
|
|
875
|
+
if text[at] == "$"
|
|
876
|
+
and (e := _dollar_end(text, at)) is not None),
|
|
877
|
+
None)
|
|
878
|
+
if body is not None:
|
|
879
|
+
tag = len(_DOLLAR_TAG.match(text, body[0]).group(0))
|
|
880
|
+
body = (text, pos, body[0] + tag, body[1] - tag, False)
|
|
881
|
+
self._procedural(line, _PROCEDURAL_LANGUAGES[lang],
|
|
882
|
+
"DO block", body)
|
|
883
|
+
else:
|
|
884
|
+
self._diagnose(line, unread_detail(stmt))
|
|
885
|
+
return end
|
|
886
|
+
obj = next((w for w in words[1:] if w not in _OBJECT_MODIFIERS), "")
|
|
887
|
+
if words[0] == "CREATE" and obj in _ROUTINES:
|
|
888
|
+
self._routine_text(stmt, text, pos, start, end, line)
|
|
889
|
+
return end
|
|
890
|
+
inner = _inner_query(text, start, end)
|
|
891
|
+
if inner is None or self._parse_piece(text, pos, *inner) is not None:
|
|
892
|
+
self._diagnose(line, unread_detail(stmt))
|
|
893
|
+
return end
|
|
894
|
+
|
|
895
|
+
def _routine_text(self, stmt, text, pos, start, end, line):
|
|
896
|
+
"""A CREATE FUNCTION / PROCEDURE sqlglot read only as a Command."""
|
|
897
|
+
lang = _language_in(text, start, end)
|
|
898
|
+
bodies = list(_string_bodies(text, start, end))
|
|
899
|
+
body = (text, pos, *bodies[0]) if bodies else None
|
|
900
|
+
block = next((e for w, _, e in _top_words(text, start, end)
|
|
901
|
+
if w == "AS" and _is_block(text[:end], e)), None)
|
|
902
|
+
if lang in _PROCEDURAL_LANGUAGES:
|
|
903
|
+
self._procedural(line, _PROCEDURAL_LANGUAGES[lang], body=body)
|
|
904
|
+
elif lang in _SQL_LANGUAGES and body:
|
|
905
|
+
self._sql_body(*body, line)
|
|
906
|
+
elif lang in _SQL_LANGUAGES and block is not None:
|
|
907
|
+
self._procedural(line, _block_name(self.dialect),
|
|
908
|
+
body=(text, pos, block, end, False))
|
|
909
|
+
else:
|
|
910
|
+
# Another language, or a body not found: as in 0.1.3.
|
|
911
|
+
self._diagnose(line, unread_detail(stmt))
|
|
912
|
+
|
|
913
|
+
def _routine(self, stmt, body, text, pos, searched):
|
|
914
|
+
"""A CREATE FUNCTION / PROCEDURE whose body sqlglot kept as text:
|
|
915
|
+
find that text in the source, then check it as SQL."""
|
|
916
|
+
content, lang = body
|
|
917
|
+
create = re.compile(r"(?<![\w$])CREATE(?![\w$])", re.IGNORECASE)
|
|
918
|
+
hit = create.search(text, searched)
|
|
919
|
+
line = self._line(self._off(pos, hit.start() if hit else searched))
|
|
920
|
+
if lang not in _SQL_LANGUAGES and lang not in _PROCEDURAL_LANGUAGES:
|
|
921
|
+
self._check(stmt, text, pos) # another language: as before
|
|
922
|
+
return searched
|
|
923
|
+
if content is None:
|
|
924
|
+
# A BEGIN … END block sqlglot parsed (loosely, for T-SQL):
|
|
925
|
+
# what it read is still checked, as before. A SQL-standard
|
|
926
|
+
# BEGIN ATOMIC body is plain SQL; T-SQL is procedural code.
|
|
927
|
+
self._check(stmt, text, pos)
|
|
928
|
+
if not re.compile(r"\bBEGIN\s+ATOMIC\b", re.IGNORECASE).search(
|
|
929
|
+
text, searched):
|
|
930
|
+
self._procedural(line, _block_name(self.dialect))
|
|
931
|
+
return searched
|
|
932
|
+
want = " ".join(content.split())
|
|
933
|
+
for lo, hi, quoted in _string_bodies(text, searched, len(text)):
|
|
934
|
+
raw = text[lo:hi]
|
|
935
|
+
got = _unquote(raw)[0] if quoted else raw
|
|
936
|
+
if " ".join(got.split()) != want:
|
|
937
|
+
continue
|
|
938
|
+
if lang in _PROCEDURAL_LANGUAGES:
|
|
939
|
+
self._procedural(line, _PROCEDURAL_LANGUAGES[lang],
|
|
940
|
+
body=(text, pos, lo, hi, quoted))
|
|
941
|
+
else:
|
|
942
|
+
self._sql_body(text, pos, lo, hi, quoted, line)
|
|
943
|
+
return hi
|
|
944
|
+
if lang in _PROCEDURAL_LANGUAGES:
|
|
945
|
+
self._procedural(line, _PROCEDURAL_LANGUAGES[lang])
|
|
946
|
+
else:
|
|
947
|
+
self._diagnose(line, "the body of this function could not be "
|
|
948
|
+
"found in the source, so no check looked inside "
|
|
949
|
+
"it")
|
|
950
|
+
return searched
|
|
951
|
+
|
|
952
|
+
def _procedural(self, line, language, what="function body", body=None):
|
|
953
|
+
"""Procedural code is not checked. Its statements that parse on
|
|
954
|
+
their own as plain SQL still are, and their findings are real;
|
|
955
|
+
the rest (control flow, variables) is not understood."""
|
|
956
|
+
if body is not None:
|
|
957
|
+
keep = len(self.diagnostics)
|
|
958
|
+
self._pieces(*body)
|
|
959
|
+
del self.diagnostics[keep:] # the body is reported once, below
|
|
960
|
+
self._diagnose(
|
|
961
|
+
line, f"TrueQuery doesn't look inside procedural code yet: the "
|
|
962
|
+
f"control flow in this {what} ({language}) was not checked; "
|
|
963
|
+
f"only its statements that parse on their own as SQL were",
|
|
964
|
+
what=f"{PROCEDURAL} {language}")
|
|
965
|
+
|
|
966
|
+
def _sql_body(self, text, pos, lo, hi, quoted, line):
|
|
967
|
+
"""Check a plain-SQL body, statement by statement, at its true
|
|
968
|
+
lines and columns. A body that starts a BEGIN … END block is
|
|
969
|
+
procedural code."""
|
|
970
|
+
raw = text[lo:hi]
|
|
971
|
+
if _is_block(_unquote(raw)[0] if quoted else raw):
|
|
972
|
+
self._procedural(line, _block_name(self.dialect),
|
|
973
|
+
body=(text, pos, lo, hi, quoted))
|
|
974
|
+
return
|
|
975
|
+
self._pieces(text, pos, lo, hi, quoted)
|
|
976
|
+
|
|
977
|
+
def _pieces(self, text, pos, lo, hi, quoted):
|
|
978
|
+
"""Parse and check each statement of a body; one that doesn't
|
|
979
|
+
parse is a diagnostic at its own line."""
|
|
980
|
+
raw = text[lo:hi]
|
|
981
|
+
body, idx = _unquote(raw) if quoted else (raw, None)
|
|
982
|
+
bpos = self._sub(pos, lo, hi, idx)
|
|
983
|
+
cleaned = strip_comments(body, self.dialect or "generic")
|
|
984
|
+
at = 0
|
|
985
|
+
for part, _ in split_statements(cleaned):
|
|
986
|
+
lo2, at = at, at + len(part)
|
|
987
|
+
if not part.strip().strip(";").strip():
|
|
988
|
+
continue
|
|
989
|
+
err = self._parse_piece(cleaned, bpos, lo2, at)
|
|
990
|
+
if err is not None:
|
|
991
|
+
detail = _ANSI.sub("", str(err)).replace("\n", " ")
|
|
992
|
+
self._diagnose(self._first_line(part, bpos[lo2:]),
|
|
993
|
+
re.sub(r"\s+", " ", detail).strip())
|
|
994
|
+
|
|
995
|
+
# -- the checks --
|
|
996
|
+
def _check(self, stmt, text, pos):
|
|
997
|
+
origin = None if pos is None else (self.text, pos)
|
|
998
|
+
loc = Locator(text, self.start_line, origin)
|
|
999
|
+
for slug, check, record, setting in self.active:
|
|
1000
|
+
for node, why, fix in check(stmt, loc, self.ctx):
|
|
1001
|
+
line, col = loc.locate(slug, node)
|
|
1002
|
+
self.findings.append(_finding(
|
|
1003
|
+
slug, _severity(record, setting, self.mode), self.mode,
|
|
1004
|
+
self.path, self.text, self.start_line, line, col, why,
|
|
1005
|
+
fix))
|
|
1006
|
+
self.findings[-1]["offset"] = self.base + loc.last_offset
|
|
1007
|
+
for suppressed in loc.suppressed:
|
|
1008
|
+
if suppressed not in self.key_lookups:
|
|
1009
|
+
self.key_lookups.append(suppressed)
|
|
528
1010
|
|
|
529
1011
|
|
|
530
1012
|
@contextlib.contextmanager
|
|
@@ -568,6 +1050,10 @@ def _intdiv_outside_strings(chunk):
|
|
|
568
1050
|
ch = chunk[i]
|
|
569
1051
|
if ch == "'":
|
|
570
1052
|
squote = not squote
|
|
1053
|
+
elif not squote and ch == "$" and (
|
|
1054
|
+
end := _dollar_end(chunk, i)) is not None:
|
|
1055
|
+
i = end # a body in another language (`//` starts a comment)
|
|
1056
|
+
continue
|
|
571
1057
|
elif not squote and chunk[i:i + 2] == "//":
|
|
572
1058
|
pre = chunk[:i]
|
|
573
1059
|
return (1 + pre.count("\n"), i - (pre.rfind("\n") + 1) + 1)
|
|
@@ -627,7 +1113,6 @@ def check_text(text, dialect=None, path="<input>", mode="build", registry=None,
|
|
|
627
1113
|
from truequery import keylookup # imports project, which imports us
|
|
628
1114
|
registry = registry or std_registry
|
|
629
1115
|
cleaned = strip_comments(strip_jinja(text), dialect or "generic")
|
|
630
|
-
findings, diagnostics, key_lookups = [], [], []
|
|
631
1116
|
chunks = split_statements(cleaned)
|
|
632
1117
|
# A file with no statements at all (blank, comments or Jinja only)
|
|
633
1118
|
# is verified. Anything else must parse: a typo or prose is "not
|
|
@@ -635,12 +1120,16 @@ def check_text(text, dialect=None, path="<input>", mode="build", registry=None,
|
|
|
635
1120
|
active = _active_checks(registry, settings, tiers, include_disabled)
|
|
636
1121
|
ctx = checks.CheckContext(dialect=dialect, path=path, mode=mode,
|
|
637
1122
|
keys=keylookup.declared_keys_for(path))
|
|
1123
|
+
run = _Pass(active, ctx, path, mode, dialect)
|
|
1124
|
+
findings, diagnostics = run.findings, run.diagnostics
|
|
638
1125
|
base = 0 # offset of the chunk in the cleaned text (chunks are contiguous)
|
|
639
1126
|
for chunk, start_line in chunks:
|
|
640
1127
|
chunk_base, base = base, base + len(chunk)
|
|
641
1128
|
try:
|
|
642
1129
|
stmts = sqlglot.parse(chunk, read=dialect or None)
|
|
643
1130
|
except Exception as exc:
|
|
1131
|
+
if run.wrapped_chunk(chunk, start_line, chunk_base):
|
|
1132
|
+
continue
|
|
644
1133
|
# A parse failure is never a silent pass: the chunk was not
|
|
645
1134
|
# checked, so the file is unverified even when a `//`
|
|
646
1135
|
# finding is salvaged from it.
|
|
@@ -659,32 +1148,13 @@ def check_text(text, dialect=None, path="<input>", mode="build", registry=None,
|
|
|
659
1148
|
diagnostics.append(_parse_diagnostic(start_line + first, chunk,
|
|
660
1149
|
exc))
|
|
661
1150
|
continue
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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
|
|
677
|
-
loc = Locator(chunk, start_line)
|
|
678
|
-
for slug, check, record, setting in active:
|
|
679
|
-
for node, why, fix in check(stmt, loc, ctx):
|
|
680
|
-
line, col = loc.locate(slug, node)
|
|
681
|
-
findings.append(_finding(
|
|
682
|
-
slug, _severity(record, setting, mode), mode, path,
|
|
683
|
-
chunk, start_line, line, col, why, fix))
|
|
684
|
-
findings[-1]["offset"] = chunk_base + loc.last_offset
|
|
685
|
-
for suppressed in loc.suppressed:
|
|
686
|
-
if suppressed not in key_lookups:
|
|
687
|
-
key_lookups.append(suppressed)
|
|
1151
|
+
# Each statement is checked; a query sqlglot read only as an
|
|
1152
|
+
# opaque Command is unwrapped and checked when it can be, and a
|
|
1153
|
+
# function body is checked as SQL. What can't be is not checked,
|
|
1154
|
+
# like any parse failure, and the chunk's other statements still
|
|
1155
|
+
# are.
|
|
1156
|
+
run.chunk(chunk, start_line, chunk_base, stmts)
|
|
1157
|
+
key_lookups = run.key_lookups
|
|
688
1158
|
findings.sort(key=lambda f: (f["line"], f["col"], f["rule"]))
|
|
689
1159
|
return {"path": path, "findings": findings, "diagnostics": diagnostics,
|
|
690
1160
|
"verified": not diagnostics, "key_lookups": key_lookups}
|