sqlassert 0.3.1__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sqlassert-0.3.1 → sqlassert-0.4.1}/.github/workflows/ci.yml +18 -4
- sqlassert-0.4.1/.github/workflows/pages.yml +41 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/.gitignore +5 -1
- sqlassert-0.4.1/AGENTS.md +86 -0
- sqlassert-0.4.1/CITATION.cff +9 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/CONTEXT.md +160 -24
- sqlassert-0.4.1/PKG-INFO +235 -0
- sqlassert-0.4.1/README.md +202 -0
- sqlassert-0.4.1/docs/adr/0002-use-a-framework-independent-ir.md +5 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/adr/0005-analyze-sql-without-a-connection.md +2 -0
- sqlassert-0.4.1/docs/adr/0006-model-only-current-strict-engines.md +9 -0
- sqlassert-0.4.1/docs/adr/0007-exact-comparisons-assume-values-in-range.md +20 -0
- sqlassert-0.4.1/docs/adr/0008-best-effort-on-sql-the-user-should-fix.md +13 -0
- sqlassert-0.4.1/docs/adr/0009-equal-and-fixing-comparisons.md +84 -0
- sqlassert-0.4.1/docs/adr/0010-what-a-rewrite-preserves.md +12 -0
- sqlassert-0.4.1/docs/assets/fan-trap.sql +9 -0
- sqlassert-0.4.1/docs/assets/inner-join.sql +9 -0
- sqlassert-0.4.1/docs/assets/redundant-join.sql +6 -0
- sqlassert-0.4.1/docs/assets/social-preview.png +0 -0
- sqlassert-0.4.1/docs/assets/sqlassert-demo-preview.png +0 -0
- sqlassert-0.4.1/docs/assets/sqlassert-demo.html +85 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/calcite-audit.md +39 -32
- sqlassert-0.4.1/docs/dialect-provenance.json +1618 -0
- sqlassert-0.4.1/docs/dialects.md +808 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/functional-dependencies.md +94 -59
- sqlassert-0.4.1/docs/implementation-conventions.md +483 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0011-fuzz-test-analyze-against-a-real-world-sql-corpus.md +5 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0027-soundness-oracle-against-duckdb.md +20 -10
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0039-smaller-lowering-gaps.md +2 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0042-lowering-support-v2.md +20 -5
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0043-external-integrations.md +4 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0046-certify-dialect-facts.md +10 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0049-collation-aware-properties.md +6 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0051-validate-snowflake-against-a-real-engine.md +4 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0052-validate-bigquery-against-a-real-engine.md +4 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0053-validate-databricks-against-a-real-engine.md +6 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/0054-validate-redshift-against-a-real-engine.md +4 -1
- sqlassert-0.4.1/docs/issues/0057-dbt-incremental-models.md +60 -0
- sqlassert-0.4.1/docs/issues/0058-dbt-source-mapping.md +59 -0
- sqlassert-0.4.1/docs/issues/0059-postgres-user-defined-functions.md +89 -0
- sqlassert-0.4.1/docs/issues/0060-audit-inference-against-cockroachdb.md +79 -0
- sqlassert-0.4.1/docs/issues/0061-symbolic-oracle-with-verieql.md +61 -0
- sqlassert-0.4.1/docs/issues/0062-cross-check-suggest-rewrites-with-equivalence-checkers.md +51 -0
- sqlassert-0.4.1/docs/issues/0063-generate-random-programs-for-the-oracle.md +51 -0
- sqlassert-0.4.1/docs/issues/0064-triage-wetune-rewrite-rules.md +36 -0
- sqlassert-0.4.1/docs/issues/0065-triage-sqlcheck-anti-patterns.md +33 -0
- sqlassert-0.4.1/docs/issues/0066-check-semantics-against-guagliardo-libkin.md +44 -0
- sqlassert-0.4.1/docs/issues/0067-recheck-calcite-funcdepset.md +28 -0
- sqlassert-0.4.1/docs/issues/0068-name-suggestion-types-by-severity.md +30 -0
- sqlassert-0.4.1/docs/issues/0069-real-world-sql-corpora.md +84 -0
- sqlassert-0.4.1/docs/issues/0070-decide-whether-to-warn-on-hidden-join-fanout-by-default.md +64 -0
- sqlassert-0.4.1/docs/issues/0073-pending-lowering-and-classification-decisions.md +132 -0
- sqlassert-0.4.1/docs/issues/0076-asof-join.md +29 -0
- sqlassert-0.4.1/docs/issues/0077-range-joins-against-constant-tables.md +36 -0
- sqlassert-0.4.1/docs/issues/0078-read-casts-that-keep-a-literals-value-in-check-constraints.md +43 -0
- sqlassert-0.4.1/docs/issues/0079-profile-and-optimize-analysis-time.md +65 -0
- sqlassert-0.4.1/docs/issues/README.md +27 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0012-add-unique-set-assertions-for-select-expressions-unique-prim.md +1 -1
- {sqlassert-0.3.1/docs/issues → sqlassert-0.4.1/docs/issues/done}/0015-suggest-provable-properties-for-unannotated-sql.md +56 -52
- {sqlassert-0.3.1/docs/issues → sqlassert-0.4.1/docs/issues/done}/0023-close-ir-lowering-gaps.md +16 -12
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0024-functional-dependency-reasoning.md +1 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0026-equality-groups.md +1 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0031-enumerated-domains-through-set-operations.md +1 -1
- {sqlassert-0.3.1/docs/issues → sqlassert-0.4.1/docs/issues/done}/0037-close-the-paulley-audit-missing-rules.md +35 -10
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0038-lower-order-by-and-select-list-subqueries.md +2 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0040-audit-inference-against-calcite.md +1 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0041-join-cardinality-markers-and-fan-trap-smell.md +1 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0044-v1-external-integrations.md +1 -1
- sqlassert-0.4.1/docs/issues/done/0045-close-the-calcite-audit-missing-proofs.md +123 -0
- sqlassert-0.4.1/docs/issues/done/0050-dbt-catalog-json.md +59 -0
- sqlassert-0.4.1/docs/issues/done/0055-dbt-suggest-model-files.md +38 -0
- sqlassert-0.4.1/docs/issues/done/0056-dbt-live-connection.md +78 -0
- sqlassert-0.4.1/docs/issues/done/0070-drop-legacy-and-permissive-dialect-support.md +51 -0
- sqlassert-0.4.1/docs/issues/done/0071-rewrites-carry-exact-edits.md +72 -0
- sqlassert-0.4.1/docs/issues/done/0072-type-computed-select-items.md +56 -0
- sqlassert-0.4.1/docs/issues/done/0074-adr-on-integer-comparisons-and-implicit-casts.md +92 -0
- sqlassert-0.4.1/docs/issues/done/0075-make-explain-lead-to-the-cause.md +430 -0
- sqlassert-0.4.1/docs/issues/list.md +118 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/literature-notes.md +16 -7
- sqlassert-0.4.1/docs/references.md +173 -0
- sqlassert-0.4.1/docs/site/cli.md +162 -0
- sqlassert-0.4.1/docs/site/codes.md +86 -0
- sqlassert-0.4.1/docs/site/dbt.md +39 -0
- sqlassert-0.4.1/docs/site/dialects.md +72 -0
- sqlassert-0.4.1/docs/site/index.md +48 -0
- sqlassert-0.4.1/docs/site/markers.md +218 -0
- sqlassert-0.4.1/docs/site/proofs.md +63 -0
- sqlassert-0.4.1/docs/site/python.md +97 -0
- sqlassert-0.4.1/docs/site/quickstart.md +77 -0
- sqlassert-0.4.1/integrations/dbt/README.md +234 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/pyproject.toml +2 -1
- sqlassert-0.4.1/integrations/dbt/sqlassert_dbt/__init__.py +21 -0
- sqlassert-0.4.1/integrations/dbt/sqlassert_dbt/__main__.py +350 -0
- sqlassert-0.4.1/integrations/dbt/sqlassert_dbt/connect.py +135 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/expectations.py +47 -6
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/jinja.py +130 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/manifest.py +108 -4
- sqlassert-0.4.1/integrations/dbt/sqlassert_dbt/program.py +1201 -0
- sqlassert-0.4.1/integrations/dbt/sqlassert_dbt/project.py +628 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/report.py +114 -4
- sqlassert-0.4.1/integrations/dbt/tests/conftest.py +50 -0
- sqlassert-0.4.1/integrations/dbt/tests/test_catalog.py +146 -0
- sqlassert-0.4.1/integrations/dbt/tests/test_connect.py +101 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/test_dbt.py +145 -4
- sqlassert-0.4.1/integrations/dbt/tests/test_file_sources.py +114 -0
- sqlassert-0.4.1/integrations/dbt/tests/test_suggest.py +325 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/poetry.lock +8 -9
- {sqlassert-0.3.1 → sqlassert-0.4.1}/pyproject.toml +9 -2
- sqlassert-0.4.1/scripts/README.md +118 -0
- sqlassert-0.4.1/scripts/audit-new-base.md +227 -0
- sqlassert-0.4.1/scripts/audit.py +601 -0
- sqlassert-0.4.1/scripts/certify_dialects.py +1083 -0
- sqlassert-0.4.1/scripts/dbt_offline.py +44 -0
- sqlassert-0.4.1/scripts/render_sqlassert_interactive_demo.py +129 -0
- sqlassert-0.4.1/scripts/render_sqlassert_social_preview.py +72 -0
- sqlassert-0.4.1/scripts/vendor_dbt_analysis.py +319 -0
- sqlassert-0.4.1/scripts/vendor_repository_inventory.py +158 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/__init__.py +1 -2
- sqlassert-0.4.1/sqlassert/__main__.py +9 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/check.py +98 -16
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/diagnostics.py +31 -7
- sqlassert-0.4.1/sqlassert/dialects.py +688 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/bigquery.py +3 -1
- sqlassert-0.4.1/sqlassert/discovery/databricks.py +41 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/duckdb.py +61 -23
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/fetcher.py +170 -45
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/information_schema.py +34 -5
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/mysql.py +22 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/postgres.py +28 -12
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/redshift.py +3 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/snowflake.py +3 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/trino.py +2 -2
- sqlassert-0.4.1/sqlassert/edits.py +240 -0
- sqlassert-0.4.1/sqlassert/hazards.py +735 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/ir/__init__.py +6 -1
- sqlassert-0.4.1/sqlassert/ir/convert/__init__.py +13 -0
- sqlassert-0.4.1/sqlassert/ir/convert/aggregation.py +439 -0
- sqlassert-0.4.1/sqlassert/ir/convert/builtins.py +140 -0
- sqlassert-0.4.1/sqlassert/ir/convert/expressions.py +572 -0
- sqlassert-0.4.1/sqlassert/ir/convert/joins.py +264 -0
- sqlassert-0.4.1/sqlassert/ir/convert/markers.py +249 -0
- sqlassert-0.4.1/sqlassert/ir/convert/parser.py +253 -0
- sqlassert-0.4.1/sqlassert/ir/convert/queries.py +259 -0
- sqlassert-0.4.1/sqlassert/ir/convert/schema.py +606 -0
- sqlassert-0.4.1/sqlassert/ir/convert/scopes.py +205 -0
- sqlassert-0.4.1/sqlassert/ir/convert/selects.py +337 -0
- sqlassert-0.4.1/sqlassert/ir/convert/shared.py +429 -0
- sqlassert-0.4.1/sqlassert/ir/convert/sources.py +432 -0
- sqlassert-0.4.1/sqlassert/ir/convert/subqueries.py +364 -0
- sqlassert-0.4.1/sqlassert/ir/convert/value_types.py +223 -0
- sqlassert-0.4.1/sqlassert/ir/convert/windows.py +275 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/ir/model.py +247 -66
- sqlassert-0.4.1/sqlassert/ir/names.py +63 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/main.py +3 -9
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/properties.py +12 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/provenance.py +5 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/python_engine.py +167 -50
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/reporting.py +36 -32
- sqlassert-0.4.1/sqlassert/rewrites.py +1591 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/rules/STYLEGUIDE.md +3 -2
- sqlassert-0.4.1/sqlassert/rules/causes/__init__.py +41 -0
- sqlassert-0.4.1/sqlassert/rules/causes/coverage.py +113 -0
- sqlassert-0.4.1/sqlassert/rules/causes/domain.py +123 -0
- sqlassert-0.4.1/sqlassert/rules/causes/joins.py +73 -0
- sqlassert-0.4.1/sqlassert/rules/causes/nulls.py +154 -0
- sqlassert-0.4.1/sqlassert/rules/causes/unique.py +523 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/rules/domain.py +123 -26
- sqlassert-0.4.1/sqlassert/rules/equality.py +301 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/rules/exactly_one.py +42 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/rules/foreign_key.py +15 -13
- sqlassert-0.4.1/sqlassert/rules/join_cardinality.py +357 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/rules/nullability.py +244 -35
- sqlassert-0.4.1/sqlassert/rules/uniqueness.py +1028 -0
- sqlassert-0.4.1/sqlassert/rules/value_typing.py +337 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/sql_parse.py +224 -90
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/suggest.py +132 -57
- sqlassert-0.4.1/sqlassert.egg-info/PKG-INFO +235 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert.egg-info/SOURCES.txt +128 -16
- sqlassert-0.4.1/sqlassert.egg-info/entry_points.txt +2 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert.egg-info/requires.txt +4 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert.egg-info/scm_file_list.json +128 -16
- sqlassert-0.4.1/sqlassert.egg-info/scm_version.json +8 -0
- sqlassert-0.4.1/sqlassert.egg-info/top_level.txt +2 -0
- sqlassert-0.3.1/sqlassert/__main__.py → sqlassert-0.4.1/sqlassert_cli.py +27 -35
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/aggregate_and_distinct.sqltest +46 -2
- sqlassert-0.4.1/tests/aggregates_in_expressions.sqltest +99 -0
- sqlassert-0.4.1/tests/always_null_columns.sqltest +57 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/calcite_audit_iq.sqltest +50 -14
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/calcite_audit_keys.sqltest +108 -29
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/calcite_audit_nulls.sqltest +307 -58
- sqlassert-0.4.1/tests/check_constraints.sqltest +98 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/composite_unique_sets.sqltest +45 -7
- sqlassert-0.4.1/tests/computed_select_item_types.sqltest +451 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/cte_and_subquery.sqltest +9 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/database_hydration.sqltest +2 -4
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/dialect_duckdb.sqltest +31 -16
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/dialect_mysql.sqltest +23 -18
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/dialect_postgres.sqltest +15 -13
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/dialect_trino.sqltest +14 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/dialect_warehouses.sqltest +70 -16
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/enumerated_domain.sqltest +27 -6
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/enumerated_domain_standalone.sqltest +1 -2
- sqlassert-0.4.1/tests/exact_comparisons.sqltest +90 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/exactly_one_join.sqltest +54 -3
- sqlassert-0.4.1/tests/fixing_comparisons.sqltest +85 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/foreign_keys.sqltest +6 -6
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/functional_dependencies.sqltest +38 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/functional_dependencies_of_functions.sqltest +75 -9
- sqlassert-0.4.1/tests/join_cardinality.sqltest +296 -0
- sqlassert-0.4.1/tests/join_kinds.sqltest +381 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/join_kinds_standalone.sqltest +1 -0
- sqlassert-0.4.1/tests/lowering_having_values_subqueries.sqltest +97 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/marker_accounting.sqltest +7 -2
- sqlassert-0.4.1/tests/nested_joins.sqltest +113 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/not_null.sqltest +39 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/not_null_rejection.sqltest +33 -6
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/not_null_values.sqltest +1 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/paulley_audit.sqltest +256 -1
- sqlassert-0.4.1/tests/qualify_by_partition.sqltest +783 -0
- sqlassert-0.4.1/tests/recursive_cte.sqltest +268 -0
- sqlassert-0.4.1/tests/review_soundness.sqltest +236 -0
- sqlassert-0.4.1/tests/root_select_body.sqltest +175 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/scalar_aggregates.sqltest +3 -3
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/scalar_subqueries.sqltest +2 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/schema_amendments.sqltest +8 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/schema_amendments_standalone.sqltest +1 -1
- sqlassert-0.4.1/tests/set_operations.sqltest +268 -0
- sqlassert-0.4.1/tests/set_returning_functions.sqltest +62 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/soundness.sqltest +2 -4
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/soundness_oracle.py +43 -17
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/sqltest.py +15 -1
- sqlassert-0.4.1/tests/star_projection.sqltest +554 -0
- sqlassert-0.4.1/tests/table_functions.sqltest +196 -0
- sqlassert-0.4.1/tests/table_functions_bigquery.sqltest +47 -0
- sqlassert-0.4.1/tests/table_functions_databricks.sqltest +9 -0
- sqlassert-0.4.1/tests/table_functions_postgres.sqltest +166 -0
- sqlassert-0.4.1/tests/table_functions_redshift.sqltest +26 -0
- sqlassert-0.4.1/tests/table_functions_spark.sqltest +37 -0
- sqlassert-0.4.1/tests/table_functions_sqlite.sqltest +23 -0
- sqlassert-0.4.1/tests/table_functions_trino.sqltest +80 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_aggregate_and_distinct.py +10 -36
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_cte_and_subquery.py +2 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_enumerated_domain.py +0 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_marker_accounting.py +4 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_qualify_by_partition.py +9 -10
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_scalar_subqueries.py +8 -8
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_unique_set_assertion.py +0 -13
- sqlassert-0.4.1/tests/test_causes.py +503 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_check.py +24 -10
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_connection_warnings.py +1 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_database_hydration.py +44 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_dialect_certification.py +33 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_dialects.py +4 -5
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_duckdb_hydration.py +49 -2
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_equality_groups.py +21 -5
- sqlassert-0.4.1/tests/test_hazards.py +987 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_ir_model.py +50 -2
- sqlassert-0.4.1/tests/test_minimal_keys.py +93 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_mysql_catalog.py +28 -5
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_postgres_catalog.py +63 -12
- sqlassert-0.4.1/tests/test_property_functions.py +19 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_python_engine.py +35 -4
- sqlassert-0.4.1/tests/test_required_columns.py +41 -0
- sqlassert-0.4.1/tests/test_review_soundness.py +104 -0
- sqlassert-0.4.1/tests/test_schema_sources.py +150 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_sql_parse.py +8 -8
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_sqltest.py +1 -1
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_suggest.py +72 -4
- sqlassert-0.4.1/tests/test_suggest_rewrites.py +1580 -0
- sqlassert-0.4.1/tests/test_unproved_join.py +251 -0
- sqlassert-0.4.1/tests/test_using_star_probe.py +55 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_warehouse_catalogs.py +20 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/unique_join.sqltest +4 -5
- sqlassert-0.4.1/tests/unsupported_constructs.sqltest +164 -0
- sqlassert-0.4.1/tests/values_types.sqltest +232 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/uv.lock +20 -20
- sqlassert-0.4.1/zensical.toml +52 -0
- sqlassert-0.3.1/AGENTS.md +0 -33
- sqlassert-0.3.1/PKG-INFO +0 -725
- sqlassert-0.3.1/README.md +0 -695
- sqlassert-0.3.1/docs/adr/0002-use-a-framework-independent-ir.md +0 -3
- sqlassert-0.3.1/docs/dialect-provenance.json +0 -685
- sqlassert-0.3.1/docs/dialects.md +0 -308
- sqlassert-0.3.1/docs/implementation-conventions.md +0 -277
- sqlassert-0.3.1/docs/issues/0045-close-the-calcite-audit-missing-proofs.md +0 -119
- sqlassert-0.3.1/docs/issues/0050-dbt-catalog-json.md +0 -32
- sqlassert-0.3.1/docs/issues/README.md +0 -80
- sqlassert-0.3.1/docs/mvp-scope.md +0 -38
- sqlassert-0.3.1/docs/references.md +0 -67
- sqlassert-0.3.1/integrations/dbt/README.md +0 -129
- sqlassert-0.3.1/integrations/dbt/sqlassert_dbt/__init__.py +0 -19
- sqlassert-0.3.1/integrations/dbt/sqlassert_dbt/__main__.py +0 -115
- sqlassert-0.3.1/integrations/dbt/sqlassert_dbt/program.py +0 -686
- sqlassert-0.3.1/integrations/dbt/sqlassert_dbt/project.py +0 -340
- sqlassert-0.3.1/integrations/dbt/tests/conftest.py +0 -16
- sqlassert-0.3.1/scripts/certify_dialects.py +0 -661
- sqlassert-0.3.1/sqlassert/dialects.py +0 -211
- sqlassert-0.3.1/sqlassert/discovery/databricks.py +0 -18
- sqlassert-0.3.1/sqlassert/improvements.py +0 -528
- sqlassert-0.3.1/sqlassert/ir/convert.py +0 -2377
- sqlassert-0.3.1/sqlassert/rules/equality.py +0 -233
- sqlassert-0.3.1/sqlassert/rules/join_cardinality.py +0 -94
- sqlassert-0.3.1/sqlassert/rules/uniqueness.py +0 -601
- sqlassert-0.3.1/sqlassert/smells.py +0 -306
- sqlassert-0.3.1/sqlassert.egg-info/PKG-INFO +0 -725
- sqlassert-0.3.1/sqlassert.egg-info/entry_points.txt +0 -2
- sqlassert-0.3.1/sqlassert.egg-info/scm_version.json +0 -8
- sqlassert-0.3.1/sqlassert.egg-info/top_level.txt +0 -1
- sqlassert-0.3.1/tests/join_cardinality.sqltest +0 -48
- sqlassert-0.3.1/tests/join_kinds.sqltest +0 -215
- sqlassert-0.3.1/tests/qualify_by_partition.sqltest +0 -37
- sqlassert-0.3.1/tests/root_select_body.sqltest +0 -79
- sqlassert-0.3.1/tests/set_operations.sqltest +0 -56
- sqlassert-0.3.1/tests/test_analyze_relation_facts.py +0 -173
- sqlassert-0.3.1/tests/test_property_functions.py +0 -18
- sqlassert-0.3.1/tests/test_smells.py +0 -170
- sqlassert-0.3.1/tests/test_suggest_improvements.py +0 -611
- sqlassert-0.3.1/tmp/clingo-rules-rebuild-assessment.md +0 -577
- sqlassert-0.3.1/tmp/sqlassert-clingo-grilling-handoff.md +0 -335
- sqlassert-0.3.1/tmp/try.py +0 -14
- {sqlassert-0.3.1 → sqlassert-0.4.1}/CLAUDE.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/LICENSE +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/case.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/adr/0001-isolate-clingo-as-the-property-engine.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/adr/0003-encode-the-ir-in-clingo.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/adr/0004-use-python-analysis-functions-for-property-inference.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/calcite-notes.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0001-spec-rewrite-the-property-engine-around-a-relational-ir-and.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0002-prove-one-declared-unique-join-through-clingo.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0003-prove-composite-and-nullable-unique-sets.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0004-propagate-uniqueness-through-relation-instances-filters-and.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0005-analyze-cte-and-from-subquery-plans.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0006-expand-create-views-with-provenance-and-cycle-detection.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0007-derive-uniqueness-from-aggregate-and-distinct.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0008-derive-uniqueness-from-qualifybypartition.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0009-return-conservative-diagnostics-for-the-complete-mvp-boundar.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0010-cut-over-to-analyze-and-retire-the-legacy-analyzer.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0013-refactoring.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0014-hydrate-analysis-from-database-catalogs-with-recursive-view.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0016-assert-and-declare-string-enum-domains.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0017-complete-typed-enum-support.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0018-assert-exhaustive-simple-case-expressions.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0019-assert-and-declare-direct-foreign-keys.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0020-propagate-foreign-keys-through-queries.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0021-assert-simple-exactly-one-joins.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0022-complete-exactly-one-reasoning.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0025-check-rule-consistency-invariants.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0028-analyze-join-markers-inside-cte-bodies.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0029-enum-string-literals-may-coincide.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0030-read-enum-types-and-collations-from-the-catalog.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0032-infer-simple-case-nullability.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0033-inner-join-suggestion-across-join-chains-and-ctes.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0034-close-soundness-oracle-blind-spots.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0035-audit-fd-propagation-against-paulley.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0036-refactor-tests-for-corpus-and-oracle-scale.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0047-discovery-base-class.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/docs/issues/done/0048-dbt-plugin-package.md +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/LICENSE +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/dbt_project.yml +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/active_customers.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customer_keys.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customer_orders.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customer_signups.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customers.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/orders_appended.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/orders_incremental.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/schema.yml +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/stg_customers.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/stg_orders.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/profiles.yml +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/seeds/raw_payments.csv +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_runs.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/integrations/dbt/tests/test_contracts.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/join.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/left.sql +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/scripts/publish-pypi.sh +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/setup.cfg +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/discovery/__init__.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/rules/__init__.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert/rules/column_set.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/sqlassert.egg-info/dependency_links.txt +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/calcite_audit.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/conftest.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/connection_warnings.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/duckdb_hydration.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/exhaustive_case.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/foreign_keys_standalone.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/functional_dependencies_standalone.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/joins_in_bodies.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/limit.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/not_null_case_expressions.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/not_null_standalone.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/propagation.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/subqueries.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_exactly_one_join.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_exhaustive_case.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_join_cardinality.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_join_kinds.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_joins_in_bodies.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_not_null.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_set_operations.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_soundness.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_unique_join.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_analyze_views.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_ir_unions.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_main.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_module_boundaries.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_oracle_plugin.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_soundness_oracle.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/test_trino_catalog.py +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/unique_set_assertion.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/unique_set_declaration.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/unique_set_declaration_standalone.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/unsupported_statements.sqltest +0 -0
- {sqlassert-0.3.1 → sqlassert-0.4.1}/tests/views.sqltest +0 -0
|
@@ -3,8 +3,8 @@ name: CI
|
|
|
3
3
|
# Tests on every push and pull request. Publishing (see the jobs at the end)
|
|
4
4
|
# happens only on a push to this repository, never on a pull request:
|
|
5
5
|
# - a push to main publishes a dev build (X.Y.Z.devN) to TestPyPI;
|
|
6
|
-
# - a tag vX.Y.Z publishes
|
|
7
|
-
#
|
|
6
|
+
# - a tag vX.Y.Z publishes the same artifacts to TestPyPI, then to PyPI
|
|
7
|
+
# (vX.Y.ZrcN is a pre-release), and creates a GitHub release.
|
|
8
8
|
# No token is stored: PyPI trusts this workflow through OIDC (Trusted
|
|
9
9
|
# Publishing), configured on pypi.org and test.pypi.org for both projects.
|
|
10
10
|
on:
|
|
@@ -32,6 +32,17 @@ jobs:
|
|
|
32
32
|
- run: ty check sqlassert tests
|
|
33
33
|
- run: python -m pytest --soundness-oracle -q
|
|
34
34
|
|
|
35
|
+
# The docs site builds with no broken link or anchor (published by pages.yml).
|
|
36
|
+
docs:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/setup-python@v5
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.13"
|
|
43
|
+
- run: pip install "zensical>=0.1.4"
|
|
44
|
+
- run: zensical build --strict
|
|
45
|
+
|
|
35
46
|
# The dbt plugin (integrations/dbt) against this checkout's sqlassert, with
|
|
36
47
|
# dbt-duckdb to compile its test project.
|
|
37
48
|
dbt-plugin:
|
|
@@ -73,7 +84,7 @@ jobs:
|
|
|
73
84
|
path: dist/
|
|
74
85
|
|
|
75
86
|
publish-testpypi:
|
|
76
|
-
if: github.event_name == 'push'
|
|
87
|
+
if: github.event_name == 'push'
|
|
77
88
|
needs: build
|
|
78
89
|
runs-on: ubuntu-latest
|
|
79
90
|
environment:
|
|
@@ -89,10 +100,13 @@ jobs:
|
|
|
89
100
|
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
90
101
|
with:
|
|
91
102
|
repository-url: https://test.pypi.org/legacy/
|
|
103
|
+
# A tag's commit is often also main's head, whose push already
|
|
104
|
+
# uploaded this same version (setuptools-scm reads the tag).
|
|
105
|
+
skip-existing: true
|
|
92
106
|
|
|
93
107
|
publish-pypi:
|
|
94
108
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
95
|
-
needs:
|
|
109
|
+
needs: publish-testpypi
|
|
96
110
|
runs-on: ubuntu-latest
|
|
97
111
|
environment:
|
|
98
112
|
name: pypi
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: Publish docs site
|
|
2
|
+
|
|
3
|
+
# The docs site (Zensical, from docs/site/) and the interactive demo,
|
|
4
|
+
# at https://polvoazul.github.io/sqlassert/ (the demo at demo.html).
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
paths:
|
|
9
|
+
- docs/site/**
|
|
10
|
+
- docs/assets/sqlassert-demo.html
|
|
11
|
+
- zensical.toml
|
|
12
|
+
- .github/workflows/pages.yml
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
concurrency:
|
|
16
|
+
group: pages
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
deploy:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
pages: write
|
|
24
|
+
id-token: write
|
|
25
|
+
environment:
|
|
26
|
+
name: github-pages
|
|
27
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v6
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.13"
|
|
33
|
+
- run: pip install "zensical>=0.1.4"
|
|
34
|
+
- run: zensical build --strict
|
|
35
|
+
- run: cp docs/assets/sqlassert-demo.html _site/demo.html
|
|
36
|
+
- uses: actions/configure-pages@v5
|
|
37
|
+
- uses: actions/upload-pages-artifact@v4
|
|
38
|
+
with:
|
|
39
|
+
path: _site
|
|
40
|
+
- uses: actions/deploy-pages@v4
|
|
41
|
+
id: deployment
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Agent Guidelines
|
|
2
|
+
|
|
3
|
+
## No backwards compatibility while in alpha
|
|
4
|
+
|
|
5
|
+
sqlassert is alpha. Code simplicity wins over compatibility:
|
|
6
|
+
|
|
7
|
+
- Replace mechanisms outright; do not keep old and new side by side.
|
|
8
|
+
- No feature flags, shims, deprecation paths, or fallback branches for old
|
|
9
|
+
behavior. They are an anchor on every later change.
|
|
10
|
+
- Delete superseded code, tests, and docs in the same change.
|
|
11
|
+
|
|
12
|
+
The one contract to keep stable is the user-facing one: the Property Markers
|
|
13
|
+
(`/**ASSERT ...**/`, `/**DECLARE ...**/`) and the Properties they introduce.
|
|
14
|
+
Internal representation (IR, analysis functions, rules) may change freely.
|
|
15
|
+
|
|
16
|
+
## Analysis works without a connection
|
|
17
|
+
|
|
18
|
+
`analyze(sql)` must work from the SQL alone ([ADR 0005](docs/adr/0005-analyze-sql-without-a-connection.md)).
|
|
19
|
+
Whenever a connection would have helped (a table with no `CREATE`, an unknown
|
|
20
|
+
column type, an ambiguous column), emit a warning Diagnostic saying what is
|
|
21
|
+
missing and how to supply it, and treat the affected facts as unknown; never
|
|
22
|
+
guess. With a connection (`analyze_database`), resolve it from the catalog. A
|
|
23
|
+
connection may only add proofs, never change what the SQL alone proves,
|
|
24
|
+
and the same schema gives the same answer from the SQL or the catalog.
|
|
25
|
+
|
|
26
|
+
## Current, strict engines only
|
|
27
|
+
|
|
28
|
+
Model each engine's latest release under its default settings, strict modes
|
|
29
|
+
on ([ADR 0006](docs/adr/0006-model-only-current-strict-engines.md)). No
|
|
30
|
+
older versions, no permissive settings (non-strict `sql_mode`, Spark ANSI
|
|
31
|
+
off), and no meaning for SQL the standard rejects but a flavor tolerates
|
|
32
|
+
(a column neither grouped nor aggregated): make it opaque and warn
|
|
33
|
+
`unsupported-construct`. Simpler code beats supporting outdated SQL.
|
|
34
|
+
|
|
35
|
+
## Best effort on SQL the user should fix, never silently
|
|
36
|
+
|
|
37
|
+
Ambiguous or engine-dependent SQL (a name a derived table repeats) gets one
|
|
38
|
+
simple reading, the same for every dialect, and always a warning saying
|
|
39
|
+
what to change ([ADR 0008](docs/adr/0008-best-effort-on-sql-the-user-should-fix.md)).
|
|
40
|
+
No per-dialect variants for it. Prefer a sure reading where telling is
|
|
41
|
+
cheap (make the doubtful facts unknown); otherwise the reading may prove,
|
|
42
|
+
since the warning carries the risk. Never a silent guess. Focus effort on
|
|
43
|
+
the common, well-defined SQL.
|
|
44
|
+
|
|
45
|
+
## Where things are
|
|
46
|
+
|
|
47
|
+
- Domain language: `CONTEXT.md`. Use its terms; it lists terms to avoid.
|
|
48
|
+
- Implementation conventions: `docs/implementation-conventions.md`.
|
|
49
|
+
- Rule style: `sqlassert/rules/STYLEGUIDE.md`.
|
|
50
|
+
- Test style: SQL cases in `tests/*.sqltest` (format in `tests/sqltest.py`;
|
|
51
|
+
see "Tests" in `docs/implementation-conventions.md`).
|
|
52
|
+
- Open work: `docs/issues/` (list in `docs/issues/list.md`). Marketing
|
|
53
|
+
work is in `docs/issues/mkt/`, client work in `docs/issues/pvt/`; both are
|
|
54
|
+
gitignored and never committed. Before opening, working on or closing an
|
|
55
|
+
issue, read `docs/issues/README.md`.
|
|
56
|
+
- Architecture decisions: `docs/adr/`.
|
|
57
|
+
|
|
58
|
+
## Testing workflow
|
|
59
|
+
|
|
60
|
+
- **On each commit:** run only the focused tests for what changed (the
|
|
61
|
+
`.sqltest` files and test modules it touches) and `ty check sqlassert
|
|
62
|
+
tests`. No full suite, no oracle.
|
|
63
|
+
- **At push time:** whoever pushes runs the full suite and
|
|
64
|
+
`pytest --soundness-oracle` on everything not yet pushed
|
|
65
|
+
(`git log @{upstream}..HEAD`), fixes any failure with that context,
|
|
66
|
+
commits the fix, runs the checks below, pushes, then updates the local
|
|
67
|
+
issue tracker (`tmp/issue_tracker.yaml`, rebuilt with
|
|
68
|
+
`tmp/build_issue_tracker.py`).
|
|
69
|
+
|
|
70
|
+
## Before pushing
|
|
71
|
+
|
|
72
|
+
The repository is public. Before every push, check that nothing private
|
|
73
|
+
leaves:
|
|
74
|
+
|
|
75
|
+
- Client work (paths, project and model names, env vars, commands run on a
|
|
76
|
+
client project) goes only in gitignored places: `docs/issues/pvt/`,
|
|
77
|
+
`docs/issues/mkt/`, `tmp/`. A public issue that comes from client work is
|
|
78
|
+
phrased without client details.
|
|
79
|
+
- No outgoing file is under those directories:
|
|
80
|
+
`git diff --name-only @{upstream}..HEAD`.
|
|
81
|
+
- No added line or commit message matches a term in
|
|
82
|
+
`docs/issues/pvt/denylist.txt`:
|
|
83
|
+
`git log -p @{upstream}..HEAD | grep -iEf <(grep -v '^#' docs/issues/pvt/denylist.txt)`
|
|
84
|
+
must print nothing. Add a term there whenever a new client name shows up.
|
|
85
|
+
|
|
86
|
+
On any hit, stop and ask; do not push.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use sqlassert in published research, please cite the version you used."
|
|
3
|
+
title: sqlassert
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- given-names: Fred
|
|
7
|
+
family-names: Israel
|
|
8
|
+
repository-code: "https://github.com/polvoazul/sqlassert"
|
|
9
|
+
license: MIT
|
|
@@ -22,25 +22,99 @@ Which inputs' rows a join can repeat, read in FROM order (the left input is
|
|
|
22
22
|
everything before the join, the right its joined source). A row of one input
|
|
23
23
|
appears once per matching row of the other, or once padded.
|
|
24
24
|
- **Many To One Join**: no left row is repeated: each matches at most one right row.
|
|
25
|
-
- **One To Many Join**: no right row is repeated.
|
|
25
|
+
- **One To Many Join**: no right row is repeated. A table function or UNNEST
|
|
26
|
+
in FROM whose argument reads the left input is one: it is evaluated once per
|
|
27
|
+
left row, so each of its rows belongs to one left row (it repeats left rows,
|
|
28
|
+
never right ones). One that does not read it is a cross join of unknown rows.
|
|
26
29
|
- **One To One Join**: neither.
|
|
27
30
|
- **Unique Join** (`UNIQUE`, `NOT MANY TO MANY`): rows of at most one input
|
|
28
31
|
are repeated; the join is not many to many.
|
|
29
32
|
A SEMI or ANTI join has no Join Cardinality: it outputs no right rows.
|
|
30
33
|
_Avoid_: Unique join marker, duplicate check, 1:N
|
|
31
34
|
|
|
35
|
+
**Unproved Join Reason**:
|
|
36
|
+
Why a join has no proved Join Cardinality, the first that applies:
|
|
37
|
+
`unsupported` (an input sqlassert does not model: LATERAL, or a table function
|
|
38
|
+
or UNNEST whose columns are not known; or the join sits in an opaque SELECT),
|
|
39
|
+
`unconstrained` (no ON equality between the inputs or to a
|
|
40
|
+
constant: a cross or range join), `unresolved-key`, `untyped-key` (with
|
|
41
|
+
where the type is lost: `values`, `computed`, `opaque-relation`,
|
|
42
|
+
`set-operation`, `table`, `type-mismatch`), `expression-key` (every equality
|
|
43
|
+
compares an expression that binds no column: a deterministic function of one
|
|
44
|
+
input's columns binds the other's column when the comparison fixes it, and
|
|
45
|
+
an injective one of a column (`-x`, `x + 1`) binds that column; a product, a
|
|
46
|
+
float, a cast to another type, a volatile function does not),
|
|
47
|
+
`no-unique-set` (the bound columns reach the Row Identity of neither input),
|
|
48
|
+
with who can act, the first that applies: `cascade` (an input has a join with
|
|
49
|
+
no proved Join Cardinality or an unsupported construct below it, so fixing that
|
|
50
|
+
may fix this one), `partial-key` (the equalities bind part of a known Unique
|
|
51
|
+
Set and the rest of ON is a range or inequality: the join is as constrained as
|
|
52
|
+
written), `undeclared-key` (no known Unique Set covers the bound columns: one
|
|
53
|
+
the project could declare). A diagnostic about a missing proof, never a claim
|
|
54
|
+
about the data: an `unconstrained` join is not shown to be many to many.
|
|
55
|
+
_Avoid_: Many-to-many join (for `unconstrained`), failure reason
|
|
56
|
+
|
|
57
|
+
**Cause**:
|
|
58
|
+
Where an UNKNOWN assertion's Property is lost, found by following its columns
|
|
59
|
+
from the asserted relation through the relations they pass through
|
|
60
|
+
(`rules/causes`, one walk per question). For a Unique Set, a Functional
|
|
61
|
+
Dependency or a Join Cardinality: a join that is not many-to-one in the
|
|
62
|
+
direction needed (with its Unproved Join Reason), a UNION no asserted column
|
|
63
|
+
separates, a computed column, or a relation whose keys the columns miss (with
|
|
64
|
+
its closest minimal keys and what each lacks). For non-null columns: a Null
|
|
65
|
+
Source. For Referential Coverage: the table with no Foreign Key, or the
|
|
66
|
+
relation that breaks it. For an Enumerated Domain: the column with no domain,
|
|
67
|
+
or the source that admits a value not listed. Tagged with who can act: `sql`
|
|
68
|
+
(the query as written loses it), `declare` (a key, NOT NULL, Foreign Key or
|
|
69
|
+
domain the tables do not declare), `sqlassert` (a construct or comparison
|
|
70
|
+
sqlassert does not see through). Read from the analyses the proof ran: never
|
|
71
|
+
a Disproof, and it never changes an outcome. Every UNKNOWN assertion has one.
|
|
72
|
+
_Avoid_: Blame, root cause, error
|
|
73
|
+
|
|
32
74
|
**Fan Trap**, **Chasm Trap**:
|
|
33
|
-
An aggregate whose argument's rows a join may repeat (a
|
|
75
|
+
An aggregate whose argument's rows a join may repeat (a Hazard). A Fan Trap
|
|
34
76
|
is through a join that is not proved to be a Unique Join; a Chasm Trap through
|
|
35
77
|
a One To Many (or Many To One) Join whose argument is on the side with one row
|
|
36
78
|
per key.
|
|
37
79
|
|
|
80
|
+
**Exact Comparison**:
|
|
81
|
+
An equality `left = right` that is equal: a TRUE comparison means both sides
|
|
82
|
+
are the same value. Both operands have a known type and each widens,
|
|
83
|
+
unchanged, into the type the engine compares in
|
|
84
|
+
([ADR 0007](docs/adr/0007-exact-comparisons-assume-values-in-range.md) lists
|
|
85
|
+
which). An unknown type is none. What an equality merges into an Equality
|
|
86
|
+
Group, and the domains and foreign-key coverage it moves, ask this
|
|
87
|
+
([ADR 0009](docs/adr/0009-equal-and-fixing-comparisons.md)).
|
|
88
|
+
_Avoid_: Same type, lossless comparison
|
|
89
|
+
|
|
90
|
+
**Fixing Comparison**:
|
|
91
|
+
An equality `a = b` that fixes `a`: once `b`'s value is known, at most one
|
|
92
|
+
value of `a` makes it TRUE. An Exact Comparison is one; so is one where the
|
|
93
|
+
engine casts a side into the other's type keeping different values
|
|
94
|
+
different, both compared by identity (a DATE beside a TIMESTAMP is its
|
|
95
|
+
midnight: each fixes the other, though they are not the same value). What an
|
|
96
|
+
equality binds as a join key, pins, or makes a Functional Dependency of, ask
|
|
97
|
+
this ([ADR 0009](docs/adr/0009-equal-and-fixing-comparisons.md)).
|
|
98
|
+
_Avoid_: Determining comparison
|
|
99
|
+
|
|
100
|
+
**Lossy Comparison**:
|
|
101
|
+
An equality comparison (`=`, `<>`, `IS [NOT] DISTINCT FROM`, an IN list or
|
|
102
|
+
subquery) whose operands both have a known type and that is not an Exact
|
|
103
|
+
Comparison because a float is on either side or because text is compared with
|
|
104
|
+
another type (a Hazard;
|
|
105
|
+
[ADR 0007](docs/adr/0007-exact-comparisons-assume-values-in-range.md) owns
|
|
106
|
+
the cases). An ordering (`<`, `>`) is none, and so is an operand whose type
|
|
107
|
+
is unknown.
|
|
108
|
+
_Avoid_: Float equality, implicit cast, float comparison (an ordering is fine),
|
|
109
|
+
precision loss, rounding comparison
|
|
110
|
+
|
|
38
111
|
**Exactly One Join Assertion**:
|
|
39
112
|
An assertion that every row of a join's left-hand input matches exactly one
|
|
40
113
|
right-hand row, so the join neither multiplies nor removes left rows and a left
|
|
41
114
|
join null-extends none of them. It combines a Many To One Join (at most one match)
|
|
42
|
-
with guaranteed matching (at least one): an ON made only of equalities
|
|
43
|
-
|
|
115
|
+
with guaranteed matching (at least one): an ON made only of equalities (`=`,
|
|
116
|
+
or `IS NOT DISTINCT FROM`, which is `=` once the left columns are non-null)
|
|
117
|
+
between left and right columns, non-null left columns, and Referential Coverage of the
|
|
44
118
|
left columns, as one tuple, onto the right columns they are paired with.
|
|
45
119
|
_Avoid_: Lookup join, mandatory join, 1:1 join
|
|
46
120
|
|
|
@@ -65,16 +139,17 @@ than no marker at all.
|
|
|
65
139
|
_Avoid_: Assertion, Property Declaration, annotation, hint
|
|
66
140
|
|
|
67
141
|
**Property**:
|
|
68
|
-
A structural semantic statement about a relation or query construct.
|
|
69
|
-
Property
|
|
70
|
-
Property Declaration lists one as accepted Knowledge
|
|
71
|
-
|
|
72
|
-
|
|
142
|
+
A structural semantic statement about a relation or query construct. A
|
|
143
|
+
**Public Property** is user-facing: an Assertion wraps one as a query, while a
|
|
144
|
+
Property Declaration lists one as accepted Knowledge (Join Cardinality, Unique
|
|
145
|
+
Set). A **Private Property** is one the analysis derives only to prove others,
|
|
146
|
+
and the user never names (Exact Comparison). An Analysis Function evaluates
|
|
147
|
+
either kind.
|
|
148
|
+
_Avoid_: Rule, flag, internal fact
|
|
73
149
|
|
|
74
150
|
**Analysis Function**:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
needed by another Analysis Function.
|
|
151
|
+
The implementation that evaluates a Property, Public or Private, or derives
|
|
152
|
+
another value, over the semantic program, returning an Analysis Result.
|
|
78
153
|
_Avoid_: Rule, property
|
|
79
154
|
|
|
80
155
|
**Analysis Result**:
|
|
@@ -84,8 +159,8 @@ and members rather than by a separate evidence object.
|
|
|
84
159
|
_Avoid_: Proof, property
|
|
85
160
|
|
|
86
161
|
**Result Value**:
|
|
87
|
-
The computed value inside an Analysis Result
|
|
88
|
-
|
|
162
|
+
The computed value inside an Analysis Result: whether a Public or Private
|
|
163
|
+
Property holds, or another derived value.
|
|
89
164
|
_Avoid_: Property, proof
|
|
90
165
|
|
|
91
166
|
**Evidence**:
|
|
@@ -111,7 +186,7 @@ An explicit report that part of a SQL program could not be analyzed, such as an
|
|
|
111
186
|
_Avoid_: Error, warning, validation failure, unknown
|
|
112
187
|
|
|
113
188
|
**Connection Warning**:
|
|
114
|
-
A Diagnostic reported apart, in `Report.warnings`, when the SQL alone lacks a fact a database connection would supply: a table with no `CREATE`, or an unqualified column more than one undeclared source may own. The affected facts are unknown; the warning names the fix. It never fails a Report, and `analyze_database` emits none ([ADR 0005](docs/adr/0005-analyze-sql-without-a-connection.md)). `Report.warnings` also carries the other facts the SQL leaves open: a key or foreign key the dialect does not enforce (`unenforced-constraint`; `RELY` or `trust_unenforced_keys`, on by default, makes it a Property Declaration, never Knowledge, and then no warning is reported),
|
|
189
|
+
A Diagnostic reported apart, in `Report.warnings`, when the SQL alone lacks a fact a database connection would supply: a table with no `CREATE`, or an unqualified column more than one undeclared source may own. The affected facts are unknown; the warning names the fix. It never fails a Report, and `analyze_database` emits none ([ADR 0005](docs/adr/0005-analyze-sql-without-a-connection.md)). `Report.warnings` also carries the other facts the SQL leaves open: a key or foreign key the dialect does not enforce (`unenforced-constraint`; `RELY` or `trust_unenforced_keys`, on by default, makes it a Property Declaration, never Knowledge, and then no warning is reported), a CHECK constraint whose shape states no Enumerated Domain (`ignored-check-constraint`), a comparison of a `CAST` of a timestamp that keeps its zone (`zoned-timestamp-cast`: Trino's), a comparison of a composite column or `CAST` whose elements may be NULL (`composite-comparison`), a name that may be one the engine gave a repeated column of a derived table (`ambiguous-duplicate-column`: DuckDB names the repeats of `k` `k_1`, `k_2`, ..., so `s.k_1` is not a real `k_1` and binds nothing), a proved Property that holds trivially because a column it names is always NULL (`always-null-column`, once per column: an empty Enumerated Domain satisfies every ENUM and EXHAUSTIVE, and NULL exempts a row from a Unique Set, a dependency's determinant, Referential Coverage and Non-Null Elements), and a function call whose result type sqlassert does not know for the dialect (`unknown-function`, where it is written: its value has no known type, so an equality on it binds nothing; a `CAST` to the type it returns fixes it). All seven are about the SQL itself, so `analyze_database` keeps them: an unenforced constraint there is one a `CREATE TABLE` declares, in the SQL or, for a catalog table's CHECK, in its declaration (a catalog key's warning comes from the catalog binding).
|
|
115
190
|
|
|
116
191
|
**Non-Null Elements**:
|
|
117
192
|
A Property of composite columns (ARRAY, ROW, MAP): no element of a listed
|
|
@@ -215,11 +290,11 @@ database enum type, though a catalog's enum type could supply it as Knowledge.
|
|
|
215
290
|
_Avoid_: Enum type, value set, check constraint
|
|
216
291
|
|
|
217
292
|
**Equality Group**:
|
|
218
|
-
An analysis-only set of one relation's output columns that carry the same value on every row: merged by strict equalities (`WHERE
|
|
293
|
+
An analysis-only set of one relation's output columns that carry the same value on every row: merged by strict equalities (`WHERE`, inner-join and semi-join `ON` `a = b`, or `a IS NOT DISTINCT FROM b`, NULL then being a shared value; a semi join's through the matched right row's columns) that are an Exact Comparison, never by an outer join's `ON`. Implicit casts and case-insensitive default collations (MySQL's) do not establish value identity; a `COLLATE` is unsupported. Stronger than a pair of Functional Dependencies, which an injective `a = f(b)` also satisfies. Value facts such as Enumerated Domains and Foreign Keys read it; uniqueness does not.
|
|
219
294
|
_Avoid_: Equivalence class, alias set
|
|
220
295
|
|
|
221
296
|
**Null Source**:
|
|
222
|
-
A reason an output column may be NULL: organically (a nullable source column, an expression whose nullability is not modelled, a NULL literal) or because an outer join padded its row. A column is non-null when it has no Null Source; a null-rejecting
|
|
297
|
+
A reason an output column may be NULL: organically (a nullable source column, an expression whose nullability is not modelled, a NULL literal) or because an outer join padded its row. A column is non-null when it has no Null Source; a condition never TRUE on the rows a join pads (null-rejecting on a padded column, or on every part of an OR over them) proves that join matched and removes that padding from every column it padded.
|
|
223
298
|
_Avoid_: Nullable flag, null-extension
|
|
224
299
|
|
|
225
300
|
**Row Identity**:
|
|
@@ -232,18 +307,79 @@ _Avoid_: Select-like expression, query, statement
|
|
|
232
307
|
|
|
233
308
|
**Attachment Site**:
|
|
234
309
|
A place in the SQL text where a Property Marker can be written: right before a
|
|
235
|
-
JOIN, right after the last token of a Select Expression
|
|
236
|
-
|
|
237
|
-
|
|
310
|
+
JOIN, right after the last token of a Select Expression (of the whole query,
|
|
311
|
+
for a set operation: its last operand ends there too, so it has none), or
|
|
312
|
+
right before a simple `CASE`. Every marker attaches at one; `suggest` names each site by its
|
|
313
|
+
line and what it marks. The Hazards of a set operation's last operand are
|
|
314
|
+
reported at that shared site, saying they are in the last operand of the
|
|
315
|
+
operator (a parenthesised last operand has a site of its own).
|
|
238
316
|
_Avoid_: Marker position, anchor
|
|
239
317
|
|
|
240
|
-
**
|
|
318
|
+
**Rewrite**:
|
|
241
319
|
A rewrite of the SQL itself, at one Attachment Site, that a Proof shows leaves
|
|
242
320
|
the program's result unchanged as a multiset: an outer join that cannot keep a
|
|
243
321
|
padded row written as an inner join, a join that is redundant or only filters,
|
|
244
|
-
a redundant `DISTINCT` or grouping column, an unused CTE.
|
|
245
|
-
|
|
246
|
-
|
|
322
|
+
a redundant `DISTINCT` or grouping column, an unused CTE. It guarantees the
|
|
323
|
+
same rows (but for the one precision case ADR 0010 accepts); a column's name,
|
|
324
|
+
type or precision may change, or its arithmetic overflow, which makes it a
|
|
325
|
+
Rewrite with Caveat.
|
|
326
|
+
Otherwise (same rows, same column names and types, no new error) it is a plain
|
|
327
|
+
Rewrite, suggestion type `rewrite`
|
|
328
|
+
([ADR 0010](docs/adr/0010-what-a-rewrite-preserves.md)). `suggest` ranks
|
|
329
|
+
Rewrites before Rewrites with Caveat, those before markers to paste, and
|
|
330
|
+
those before Hazards. Every
|
|
331
|
+
Rewrite is made by its Rewrite Edits, and is offered only with them.
|
|
332
|
+
_Avoid_: Improvement, optimization, lint, hint
|
|
333
|
+
|
|
334
|
+
**Rewrite Edit**:
|
|
335
|
+
One exact text change a Rewrite makes to the SQL it was found in: replace
|
|
336
|
+
the text between two source offsets with a replacement, placed from the
|
|
337
|
+
SQL's tokens. An edit never deletes a comment or Property Marker in the text
|
|
338
|
+
it replaces: it keeps them. What `suggest` shows of a Rewrite (the rewritten
|
|
339
|
+
SQL, its diff, the dbt diff against the compiled SQL) is derived from its
|
|
340
|
+
edits, and the equivalence tests run exactly the SQL they make.
|
|
341
|
+
_Avoid_: Patch, fix, rewritten query (for the edits themselves)
|
|
342
|
+
|
|
343
|
+
**Rewrite with Caveat**:
|
|
344
|
+
A Rewrite that may change an output column's name, type, precision or
|
|
345
|
+
overflow, its message naming the column and the risk (suggestion type
|
|
346
|
+
`rewrite with caveat`): a `GROUP BY` whose groups are single rows, written
|
|
347
|
+
as a projection, replaces `sum(x)` by `x` (DuckDB's HUGEINT sum becomes x's
|
|
348
|
+
INTEGER, and `sum(x) + 1` as `x + 1` may overflow) and `avg(b)` of a BIGINT
|
|
349
|
+
by `b` (exact, where avg's DOUBLE may round). Names, and type changes that
|
|
350
|
+
reach a condition, are in
|
|
351
|
+
[ADR 0010](docs/adr/0010-what-a-rewrite-preserves.md). A
|
|
352
|
+
replacement whose value differs otherwise (`sum` of a BOOLEAN counts it) or
|
|
353
|
+
whose type is unknown is no Rewrite.
|
|
354
|
+
_Avoid_: Unsafe rewrite, approximate rewrite, lossy rewrite
|
|
355
|
+
|
|
356
|
+
**Implied Condition**:
|
|
357
|
+
A conjunct of a WHERE or ON that the other conjuncts and the input's facts
|
|
358
|
+
make TRUE on every row whose columns it reads are non-null: an equality two
|
|
359
|
+
others chain, two sides pinned to one value, a self-join's copies of one
|
|
360
|
+
column, a list holding the column's whole Enumerated Domain. Its Rewrite
|
|
361
|
+
deletes it, or, where a column may be NULL, weakens it to `IS NOT NULL`.
|
|
362
|
+
Calcite's term (`RexSimplify`: terms "implied by predicates" are removed or
|
|
363
|
+
weakened); Paulley's subsumed predicate.
|
|
364
|
+
_Avoid_: Redundant condition (the literature's redundant predicates are the
|
|
365
|
+
ones an optimizer adds), subsumed predicate, tautology
|
|
366
|
+
|
|
367
|
+
**Hazard**:
|
|
368
|
+
A place whose result the SQL leaves unspecified or likely wrong, with the
|
|
369
|
+
failed Proof that would have pinned it: a Fan Trap or Chasm Trap, an unmarked
|
|
370
|
+
join that may be many to many, a `LIMIT`
|
|
371
|
+
that picks arbitrary rows among ties, a scalar subquery that may return more
|
|
372
|
+
than one row, an equality that is not an Exact Comparison, because it casts
|
|
373
|
+
text or involves a float (a Lossy Comparison), a CASE whose results have different types (the
|
|
374
|
+
common-type cast may lose information), a query that never returns a row,
|
|
375
|
+
a strange construct (a star beside GROUP BY, QUALIFY beside an aggregate with
|
|
376
|
+
no GROUP BY, a constant PARTITION BY key in any window: read from the syntax,
|
|
377
|
+
with no proof to fail), a select that outputs one name twice (a reference reads
|
|
378
|
+
only the first; the engine renames the others).
|
|
379
|
+
The SQL may be what its author meant. `suggest` lists Hazards last; the
|
|
380
|
+
suggestion's type (`SuggestType`) is rewrite, rewrite with caveat, marker or
|
|
381
|
+
hazard.
|
|
382
|
+
_Avoid_: Smell, code smell, lint, warning; "level" for the suggestion's type
|
|
247
383
|
|
|
248
384
|
**Create Statement**:
|
|
249
385
|
A top-level SQL declaration that introduces a Named Relation or related schema Knowledge into the analyzed program.
|