sqlassert 0.3.3__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.
Files changed (394) hide show
  1. {sqlassert-0.3.3 → sqlassert-0.4.1}/.github/workflows/ci.yml +18 -4
  2. sqlassert-0.3.3/.github/workflows/demo-pages.yml → sqlassert-0.4.1/.github/workflows/pages.yml +13 -9
  3. {sqlassert-0.3.3 → sqlassert-0.4.1}/.gitignore +5 -2
  4. {sqlassert-0.3.3 → sqlassert-0.4.1}/AGENTS.md +15 -3
  5. {sqlassert-0.3.3 → sqlassert-0.4.1}/CONTEXT.md +114 -42
  6. sqlassert-0.4.1/PKG-INFO +235 -0
  7. sqlassert-0.4.1/README.md +202 -0
  8. sqlassert-0.4.1/docs/adr/0002-use-a-framework-independent-ir.md +5 -0
  9. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/adr/0005-analyze-sql-without-a-connection.md +2 -0
  10. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/adr/0006-model-only-current-strict-engines.md +3 -1
  11. sqlassert-0.4.1/docs/adr/0007-exact-comparisons-assume-values-in-range.md +20 -0
  12. sqlassert-0.4.1/docs/adr/0008-best-effort-on-sql-the-user-should-fix.md +13 -0
  13. sqlassert-0.4.1/docs/adr/0009-equal-and-fixing-comparisons.md +84 -0
  14. sqlassert-0.4.1/docs/adr/0010-what-a-rewrite-preserves.md +12 -0
  15. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/calcite-audit.md +5 -5
  16. sqlassert-0.4.1/docs/dialect-provenance.json +1618 -0
  17. sqlassert-0.4.1/docs/dialects.md +808 -0
  18. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/functional-dependencies.md +25 -16
  19. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/implementation-conventions.md +184 -32
  20. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0027-soundness-oracle-against-duckdb.md +11 -7
  21. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0042-lowering-support-v2.md +7 -1
  22. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0053-validate-databricks-against-a-real-engine.md +1 -0
  23. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0057-dbt-incremental-models.md +2 -1
  24. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0061-symbolic-oracle-with-verieql.md +4 -2
  25. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0070-decide-whether-to-warn-on-hidden-join-fanout-by-default.md +17 -1
  26. sqlassert-0.4.1/docs/issues/0073-pending-lowering-and-classification-decisions.md +132 -0
  27. sqlassert-0.4.1/docs/issues/0076-asof-join.md +29 -0
  28. sqlassert-0.4.1/docs/issues/0077-range-joins-against-constant-tables.md +36 -0
  29. sqlassert-0.4.1/docs/issues/0078-read-casts-that-keep-a-literals-value-in-check-constraints.md +43 -0
  30. sqlassert-0.4.1/docs/issues/0079-profile-and-optimize-analysis-time.md +65 -0
  31. sqlassert-0.4.1/docs/issues/README.md +27 -0
  32. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0012-add-unique-set-assertions-for-select-expressions-unique-prim.md +1 -1
  33. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0023-close-ir-lowering-gaps.md +1 -1
  34. sqlassert-0.4.1/docs/issues/done/0072-type-computed-select-items.md +56 -0
  35. sqlassert-0.4.1/docs/issues/done/0074-adr-on-integer-comparisons-and-implicit-casts.md +92 -0
  36. sqlassert-0.4.1/docs/issues/done/0075-make-explain-lead-to-the-cause.md +430 -0
  37. sqlassert-0.3.3/docs/issues/README.md → sqlassert-0.4.1/docs/issues/list.md +22 -8
  38. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/literature-notes.md +16 -7
  39. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/references.md +18 -1
  40. sqlassert-0.4.1/docs/site/cli.md +162 -0
  41. sqlassert-0.4.1/docs/site/codes.md +86 -0
  42. sqlassert-0.4.1/docs/site/dbt.md +39 -0
  43. sqlassert-0.4.1/docs/site/dialects.md +72 -0
  44. sqlassert-0.4.1/docs/site/index.md +48 -0
  45. sqlassert-0.4.1/docs/site/markers.md +218 -0
  46. sqlassert-0.4.1/docs/site/proofs.md +63 -0
  47. sqlassert-0.4.1/docs/site/python.md +97 -0
  48. sqlassert-0.4.1/docs/site/quickstart.md +77 -0
  49. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/expectations.py +47 -6
  50. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/manifest.py +52 -2
  51. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/program.py +187 -125
  52. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/project.py +7 -1
  53. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/conftest.py +7 -0
  54. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/test_dbt.py +52 -0
  55. sqlassert-0.4.1/integrations/dbt/tests/test_file_sources.py +114 -0
  56. {sqlassert-0.3.3 → sqlassert-0.4.1}/pyproject.toml +4 -0
  57. sqlassert-0.4.1/scripts/README.md +118 -0
  58. sqlassert-0.4.1/scripts/audit-new-base.md +227 -0
  59. sqlassert-0.4.1/scripts/audit.py +601 -0
  60. {sqlassert-0.3.3 → sqlassert-0.4.1}/scripts/certify_dialects.py +397 -30
  61. sqlassert-0.4.1/scripts/dbt_offline.py +44 -0
  62. sqlassert-0.4.1/scripts/vendor_dbt_analysis.py +319 -0
  63. sqlassert-0.4.1/scripts/vendor_repository_inventory.py +158 -0
  64. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/__init__.py +1 -2
  65. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/check.py +88 -13
  66. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/diagnostics.py +17 -6
  67. sqlassert-0.4.1/sqlassert/dialects.py +688 -0
  68. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/bigquery.py +3 -1
  69. sqlassert-0.4.1/sqlassert/discovery/databricks.py +41 -0
  70. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/duckdb.py +49 -7
  71. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/fetcher.py +130 -21
  72. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/information_schema.py +30 -2
  73. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/mysql.py +22 -1
  74. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/postgres.py +22 -5
  75. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/redshift.py +3 -2
  76. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/snowflake.py +3 -0
  77. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/trino.py +2 -2
  78. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/hazards.py +248 -87
  79. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/ir/__init__.py +4 -1
  80. sqlassert-0.4.1/sqlassert/ir/convert/__init__.py +13 -0
  81. sqlassert-0.4.1/sqlassert/ir/convert/aggregation.py +439 -0
  82. sqlassert-0.4.1/sqlassert/ir/convert/builtins.py +140 -0
  83. sqlassert-0.4.1/sqlassert/ir/convert/expressions.py +572 -0
  84. sqlassert-0.4.1/sqlassert/ir/convert/joins.py +264 -0
  85. sqlassert-0.4.1/sqlassert/ir/convert/markers.py +249 -0
  86. sqlassert-0.4.1/sqlassert/ir/convert/parser.py +253 -0
  87. sqlassert-0.4.1/sqlassert/ir/convert/queries.py +259 -0
  88. sqlassert-0.4.1/sqlassert/ir/convert/schema.py +606 -0
  89. sqlassert-0.4.1/sqlassert/ir/convert/scopes.py +205 -0
  90. sqlassert-0.4.1/sqlassert/ir/convert/selects.py +337 -0
  91. sqlassert-0.4.1/sqlassert/ir/convert/shared.py +429 -0
  92. sqlassert-0.4.1/sqlassert/ir/convert/sources.py +432 -0
  93. sqlassert-0.4.1/sqlassert/ir/convert/subqueries.py +364 -0
  94. sqlassert-0.4.1/sqlassert/ir/convert/value_types.py +223 -0
  95. sqlassert-0.4.1/sqlassert/ir/convert/windows.py +275 -0
  96. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/ir/model.py +125 -47
  97. sqlassert-0.4.1/sqlassert/ir/names.py +63 -0
  98. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/properties.py +12 -1
  99. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/provenance.py +5 -1
  100. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/python_engine.py +104 -44
  101. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/reporting.py +33 -32
  102. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rewrites.py +111 -61
  103. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/STYLEGUIDE.md +3 -2
  104. sqlassert-0.4.1/sqlassert/rules/causes/__init__.py +41 -0
  105. sqlassert-0.4.1/sqlassert/rules/causes/coverage.py +113 -0
  106. sqlassert-0.4.1/sqlassert/rules/causes/domain.py +123 -0
  107. sqlassert-0.4.1/sqlassert/rules/causes/joins.py +73 -0
  108. sqlassert-0.4.1/sqlassert/rules/causes/nulls.py +154 -0
  109. sqlassert-0.4.1/sqlassert/rules/causes/unique.py +523 -0
  110. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/domain.py +8 -7
  111. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/equality.py +6 -147
  112. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/exactly_one.py +2 -1
  113. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/foreign_key.py +8 -9
  114. sqlassert-0.4.1/sqlassert/rules/join_cardinality.py +357 -0
  115. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/nullability.py +5 -5
  116. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/uniqueness.py +171 -47
  117. sqlassert-0.4.1/sqlassert/rules/value_typing.py +337 -0
  118. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/sql_parse.py +28 -1
  119. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/suggest.py +11 -15
  120. sqlassert-0.4.1/sqlassert.egg-info/PKG-INFO +235 -0
  121. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert.egg-info/SOURCES.txt +74 -5
  122. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert.egg-info/requires.txt +3 -0
  123. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert.egg-info/scm_file_list.json +75 -6
  124. sqlassert-0.4.1/sqlassert.egg-info/scm_version.json +8 -0
  125. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/aggregate_and_distinct.sqltest +2 -2
  126. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/calcite_audit_keys.sqltest +3 -2
  127. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/calcite_audit_nulls.sqltest +3 -3
  128. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/check_constraints.sqltest +45 -0
  129. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/composite_unique_sets.sqltest +1 -2
  130. sqlassert-0.4.1/tests/computed_select_item_types.sqltest +451 -0
  131. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/cte_and_subquery.sqltest +9 -0
  132. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/dialect_duckdb.sqltest +3 -3
  133. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/dialect_mysql.sqltest +4 -4
  134. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/dialect_postgres.sqltest +1 -1
  135. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/dialect_trino.sqltest +1 -1
  136. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/dialect_warehouses.sqltest +17 -11
  137. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/enumerated_domain.sqltest +8 -1
  138. sqlassert-0.4.1/tests/exact_comparisons.sqltest +90 -0
  139. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/exactly_one_join.sqltest +10 -0
  140. sqlassert-0.4.1/tests/fixing_comparisons.sqltest +85 -0
  141. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/functional_dependencies_of_functions.sqltest +67 -7
  142. sqlassert-0.4.1/tests/join_cardinality.sqltest +296 -0
  143. sqlassert-0.4.1/tests/join_kinds.sqltest +381 -0
  144. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/join_kinds_standalone.sqltest +1 -0
  145. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/lowering_having_values_subqueries.sqltest +1 -1
  146. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/nested_joins.sqltest +3 -3
  147. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/not_null.sqltest +7 -1
  148. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/not_null_rejection.sqltest +2 -2
  149. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/not_null_values.sqltest +1 -1
  150. sqlassert-0.4.1/tests/qualify_by_partition.sqltest +783 -0
  151. sqlassert-0.4.1/tests/recursive_cte.sqltest +268 -0
  152. sqlassert-0.4.1/tests/review_soundness.sqltest +236 -0
  153. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/root_select_body.sqltest +74 -0
  154. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/schema_amendments.sqltest +1 -1
  155. sqlassert-0.4.1/tests/set_operations.sqltest +268 -0
  156. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/set_returning_functions.sqltest +1 -1
  157. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/soundness_oracle.py +7 -3
  158. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/sqltest.py +15 -1
  159. sqlassert-0.4.1/tests/star_projection.sqltest +554 -0
  160. sqlassert-0.4.1/tests/table_functions.sqltest +196 -0
  161. sqlassert-0.4.1/tests/table_functions_bigquery.sqltest +47 -0
  162. sqlassert-0.4.1/tests/table_functions_databricks.sqltest +9 -0
  163. sqlassert-0.4.1/tests/table_functions_postgres.sqltest +166 -0
  164. sqlassert-0.4.1/tests/table_functions_redshift.sqltest +26 -0
  165. sqlassert-0.4.1/tests/table_functions_spark.sqltest +37 -0
  166. sqlassert-0.4.1/tests/table_functions_sqlite.sqltest +23 -0
  167. sqlassert-0.4.1/tests/table_functions_trino.sqltest +80 -0
  168. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_aggregate_and_distinct.py +9 -15
  169. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_qualify_by_partition.py +9 -10
  170. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_unique_set_assertion.py +0 -13
  171. sqlassert-0.4.1/tests/test_causes.py +503 -0
  172. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_check.py +8 -6
  173. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_database_hydration.py +44 -1
  174. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_dialect_certification.py +12 -2
  175. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_duckdb_hydration.py +48 -1
  176. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_equality_groups.py +13 -1
  177. sqlassert-0.4.1/tests/test_hazards.py +987 -0
  178. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_ir_model.py +21 -1
  179. sqlassert-0.4.1/tests/test_minimal_keys.py +93 -0
  180. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_mysql_catalog.py +26 -3
  181. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_postgres_catalog.py +53 -4
  182. sqlassert-0.4.1/tests/test_property_functions.py +19 -0
  183. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_python_engine.py +35 -4
  184. sqlassert-0.4.1/tests/test_required_columns.py +41 -0
  185. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_review_soundness.py +2 -6
  186. sqlassert-0.4.1/tests/test_schema_sources.py +150 -0
  187. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_suggest.py +32 -1
  188. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_suggest_rewrites.py +167 -11
  189. sqlassert-0.4.1/tests/test_unproved_join.py +251 -0
  190. sqlassert-0.4.1/tests/test_using_star_probe.py +55 -0
  191. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_warehouse_catalogs.py +20 -0
  192. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/unsupported_constructs.sqltest +72 -1
  193. sqlassert-0.4.1/tests/values_types.sqltest +232 -0
  194. sqlassert-0.4.1/zensical.toml +52 -0
  195. sqlassert-0.3.3/PKG-INFO +0 -807
  196. sqlassert-0.3.3/README.md +0 -777
  197. sqlassert-0.3.3/docs/adr/0002-use-a-framework-independent-ir.md +0 -3
  198. sqlassert-0.3.3/docs/dialect-provenance.json +0 -880
  199. sqlassert-0.3.3/docs/dialects.md +0 -365
  200. sqlassert-0.3.3/docs/mvp-scope.md +0 -38
  201. sqlassert-0.3.3/docs/site/index.html +0 -18
  202. sqlassert-0.3.3/scripts/README.md +0 -14
  203. sqlassert-0.3.3/sqlassert/dialects.py +0 -258
  204. sqlassert-0.3.3/sqlassert/discovery/databricks.py +0 -18
  205. sqlassert-0.3.3/sqlassert/ir/convert.py +0 -3509
  206. sqlassert-0.3.3/sqlassert/rules/join_cardinality.py +0 -116
  207. sqlassert-0.3.3/sqlassert.egg-info/PKG-INFO +0 -807
  208. sqlassert-0.3.3/sqlassert.egg-info/scm_version.json +0 -8
  209. sqlassert-0.3.3/tests/join_cardinality.sqltest +0 -48
  210. sqlassert-0.3.3/tests/join_kinds.sqltest +0 -215
  211. sqlassert-0.3.3/tests/qualify_by_partition.sqltest +0 -80
  212. sqlassert-0.3.3/tests/review_soundness.sqltest +0 -80
  213. sqlassert-0.3.3/tests/set_operations.sqltest +0 -73
  214. sqlassert-0.3.3/tests/test_analyze_relation_facts.py +0 -173
  215. sqlassert-0.3.3/tests/test_hazards.py +0 -386
  216. sqlassert-0.3.3/tests/test_property_functions.py +0 -18
  217. {sqlassert-0.3.3 → sqlassert-0.4.1}/CITATION.cff +0 -0
  218. {sqlassert-0.3.3 → sqlassert-0.4.1}/CLAUDE.md +0 -0
  219. {sqlassert-0.3.3 → sqlassert-0.4.1}/LICENSE +0 -0
  220. {sqlassert-0.3.3 → sqlassert-0.4.1}/case.sql +0 -0
  221. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/adr/0001-isolate-clingo-as-the-property-engine.md +0 -0
  222. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/adr/0003-encode-the-ir-in-clingo.md +0 -0
  223. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/adr/0004-use-python-analysis-functions-for-property-inference.md +0 -0
  224. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/assets/fan-trap.sql +0 -0
  225. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/assets/inner-join.sql +0 -0
  226. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/assets/redundant-join.sql +0 -0
  227. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/assets/social-preview.png +0 -0
  228. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/assets/sqlassert-demo-preview.png +0 -0
  229. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/assets/sqlassert-demo.html +0 -0
  230. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/calcite-notes.md +0 -0
  231. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0011-fuzz-test-analyze-against-a-real-world-sql-corpus.md +0 -0
  232. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0039-smaller-lowering-gaps.md +0 -0
  233. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0043-external-integrations.md +0 -0
  234. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0046-certify-dialect-facts.md +0 -0
  235. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0049-collation-aware-properties.md +0 -0
  236. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0051-validate-snowflake-against-a-real-engine.md +0 -0
  237. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0052-validate-bigquery-against-a-real-engine.md +0 -0
  238. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0054-validate-redshift-against-a-real-engine.md +0 -0
  239. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0058-dbt-source-mapping.md +0 -0
  240. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0059-postgres-user-defined-functions.md +0 -0
  241. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0060-audit-inference-against-cockroachdb.md +0 -0
  242. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0062-cross-check-suggest-rewrites-with-equivalence-checkers.md +0 -0
  243. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0063-generate-random-programs-for-the-oracle.md +0 -0
  244. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0064-triage-wetune-rewrite-rules.md +0 -0
  245. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0065-triage-sqlcheck-anti-patterns.md +0 -0
  246. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0066-check-semantics-against-guagliardo-libkin.md +0 -0
  247. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0067-recheck-calcite-funcdepset.md +0 -0
  248. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0068-name-suggestion-types-by-severity.md +0 -0
  249. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/0069-real-world-sql-corpora.md +0 -0
  250. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0001-spec-rewrite-the-property-engine-around-a-relational-ir-and.md +0 -0
  251. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0002-prove-one-declared-unique-join-through-clingo.md +0 -0
  252. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0003-prove-composite-and-nullable-unique-sets.md +0 -0
  253. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0004-propagate-uniqueness-through-relation-instances-filters-and.md +0 -0
  254. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0005-analyze-cte-and-from-subquery-plans.md +0 -0
  255. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0006-expand-create-views-with-provenance-and-cycle-detection.md +0 -0
  256. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0007-derive-uniqueness-from-aggregate-and-distinct.md +0 -0
  257. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0008-derive-uniqueness-from-qualifybypartition.md +0 -0
  258. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0009-return-conservative-diagnostics-for-the-complete-mvp-boundar.md +0 -0
  259. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0010-cut-over-to-analyze-and-retire-the-legacy-analyzer.md +0 -0
  260. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0013-refactoring.md +0 -0
  261. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0014-hydrate-analysis-from-database-catalogs-with-recursive-view.md +0 -0
  262. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0015-suggest-provable-properties-for-unannotated-sql.md +0 -0
  263. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0016-assert-and-declare-string-enum-domains.md +0 -0
  264. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0017-complete-typed-enum-support.md +0 -0
  265. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0018-assert-exhaustive-simple-case-expressions.md +0 -0
  266. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0019-assert-and-declare-direct-foreign-keys.md +0 -0
  267. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0020-propagate-foreign-keys-through-queries.md +0 -0
  268. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0021-assert-simple-exactly-one-joins.md +0 -0
  269. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0022-complete-exactly-one-reasoning.md +0 -0
  270. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0024-functional-dependency-reasoning.md +0 -0
  271. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0025-check-rule-consistency-invariants.md +0 -0
  272. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0026-equality-groups.md +0 -0
  273. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0028-analyze-join-markers-inside-cte-bodies.md +0 -0
  274. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0029-enum-string-literals-may-coincide.md +0 -0
  275. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0030-read-enum-types-and-collations-from-the-catalog.md +0 -0
  276. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0031-enumerated-domains-through-set-operations.md +0 -0
  277. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0032-infer-simple-case-nullability.md +0 -0
  278. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0033-inner-join-suggestion-across-join-chains-and-ctes.md +0 -0
  279. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0034-close-soundness-oracle-blind-spots.md +0 -0
  280. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0035-audit-fd-propagation-against-paulley.md +0 -0
  281. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0036-refactor-tests-for-corpus-and-oracle-scale.md +0 -0
  282. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0037-close-the-paulley-audit-missing-rules.md +0 -0
  283. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0038-lower-order-by-and-select-list-subqueries.md +0 -0
  284. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0040-audit-inference-against-calcite.md +0 -0
  285. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0041-join-cardinality-markers-and-fan-trap-smell.md +0 -0
  286. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0044-v1-external-integrations.md +0 -0
  287. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0045-close-the-calcite-audit-missing-proofs.md +0 -0
  288. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0047-discovery-base-class.md +0 -0
  289. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0048-dbt-plugin-package.md +0 -0
  290. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0050-dbt-catalog-json.md +0 -0
  291. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0055-dbt-suggest-model-files.md +0 -0
  292. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0056-dbt-live-connection.md +0 -0
  293. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0070-drop-legacy-and-permissive-dialect-support.md +0 -0
  294. {sqlassert-0.3.3 → sqlassert-0.4.1}/docs/issues/done/0071-rewrites-carry-exact-edits.md +0 -0
  295. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/LICENSE +0 -0
  296. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/README.md +0 -0
  297. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/pyproject.toml +0 -0
  298. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/__init__.py +0 -0
  299. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/__main__.py +0 -0
  300. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/connect.py +0 -0
  301. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/jinja.py +0 -0
  302. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/sqlassert_dbt/report.py +0 -0
  303. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/dbt_project.yml +0 -0
  304. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/active_customers.sql +0 -0
  305. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customer_keys.sql +0 -0
  306. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customer_orders.sql +0 -0
  307. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customer_signups.sql +0 -0
  308. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/customers.sql +0 -0
  309. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/orders_appended.sql +0 -0
  310. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/orders_incremental.sql +0 -0
  311. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/schema.yml +0 -0
  312. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/stg_customers.sql +0 -0
  313. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/models/stg_orders.sql +0 -0
  314. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/profiles.yml +0 -0
  315. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_project/seeds/raw_payments.csv +0 -0
  316. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/dbt_runs.py +0 -0
  317. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/test_catalog.py +0 -0
  318. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/test_connect.py +0 -0
  319. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/test_contracts.py +0 -0
  320. {sqlassert-0.3.3 → sqlassert-0.4.1}/integrations/dbt/tests/test_suggest.py +0 -0
  321. {sqlassert-0.3.3 → sqlassert-0.4.1}/join.sql +0 -0
  322. {sqlassert-0.3.3 → sqlassert-0.4.1}/left.sql +0 -0
  323. {sqlassert-0.3.3 → sqlassert-0.4.1}/poetry.lock +0 -0
  324. {sqlassert-0.3.3 → sqlassert-0.4.1}/scripts/publish-pypi.sh +0 -0
  325. {sqlassert-0.3.3 → sqlassert-0.4.1}/scripts/render_sqlassert_interactive_demo.py +0 -0
  326. {sqlassert-0.3.3 → sqlassert-0.4.1}/scripts/render_sqlassert_social_preview.py +0 -0
  327. {sqlassert-0.3.3 → sqlassert-0.4.1}/setup.cfg +0 -0
  328. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/__main__.py +0 -0
  329. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/discovery/__init__.py +0 -0
  330. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/edits.py +0 -0
  331. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/main.py +0 -0
  332. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/__init__.py +0 -0
  333. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert/rules/column_set.py +0 -0
  334. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert.egg-info/dependency_links.txt +0 -0
  335. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert.egg-info/entry_points.txt +0 -0
  336. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert.egg-info/top_level.txt +0 -0
  337. {sqlassert-0.3.3 → sqlassert-0.4.1}/sqlassert_cli.py +0 -0
  338. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/aggregates_in_expressions.sqltest +0 -0
  339. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/always_null_columns.sqltest +0 -0
  340. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/calcite_audit.sqltest +0 -0
  341. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/calcite_audit_iq.sqltest +0 -0
  342. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/conftest.py +0 -0
  343. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/connection_warnings.sqltest +0 -0
  344. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/database_hydration.sqltest +0 -0
  345. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/duckdb_hydration.sqltest +0 -0
  346. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/enumerated_domain_standalone.sqltest +0 -0
  347. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/exhaustive_case.sqltest +0 -0
  348. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/foreign_keys.sqltest +0 -0
  349. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/foreign_keys_standalone.sqltest +0 -0
  350. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/functional_dependencies.sqltest +0 -0
  351. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/functional_dependencies_standalone.sqltest +0 -0
  352. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/joins_in_bodies.sqltest +0 -0
  353. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/limit.sqltest +0 -0
  354. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/marker_accounting.sqltest +0 -0
  355. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/not_null_case_expressions.sqltest +0 -0
  356. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/not_null_standalone.sqltest +0 -0
  357. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/paulley_audit.sqltest +0 -0
  358. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/propagation.sqltest +0 -0
  359. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/scalar_aggregates.sqltest +0 -0
  360. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/scalar_subqueries.sqltest +0 -0
  361. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/schema_amendments_standalone.sqltest +0 -0
  362. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/soundness.sqltest +0 -0
  363. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/subqueries.sqltest +0 -0
  364. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_cte_and_subquery.py +0 -0
  365. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_enumerated_domain.py +0 -0
  366. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_exactly_one_join.py +0 -0
  367. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_exhaustive_case.py +0 -0
  368. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_join_cardinality.py +0 -0
  369. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_join_kinds.py +0 -0
  370. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_joins_in_bodies.py +0 -0
  371. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_marker_accounting.py +0 -0
  372. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_not_null.py +0 -0
  373. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_scalar_subqueries.py +0 -0
  374. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_set_operations.py +0 -0
  375. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_soundness.py +0 -0
  376. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_unique_join.py +0 -0
  377. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_analyze_views.py +0 -0
  378. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_connection_warnings.py +0 -0
  379. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_dialects.py +0 -0
  380. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_ir_unions.py +0 -0
  381. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_main.py +0 -0
  382. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_module_boundaries.py +0 -0
  383. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_oracle_plugin.py +0 -0
  384. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_soundness_oracle.py +0 -0
  385. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_sql_parse.py +0 -0
  386. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_sqltest.py +0 -0
  387. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/test_trino_catalog.py +0 -0
  388. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/unique_join.sqltest +0 -0
  389. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/unique_set_assertion.sqltest +0 -0
  390. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/unique_set_declaration.sqltest +0 -0
  391. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/unique_set_declaration_standalone.sqltest +0 -0
  392. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/unsupported_statements.sqltest +0 -0
  393. {sqlassert-0.3.3 → sqlassert-0.4.1}/tests/views.sqltest +0 -0
  394. {sqlassert-0.3.3 → sqlassert-0.4.1}/uv.lock +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 to PyPI (vX.Y.ZrcN: a pre-release, which pip
7
- # installs only with --pre) and creates a GitHub release.
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' && github.ref == 'refs/heads/main'
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: build
109
+ needs: publish-testpypi
96
110
  runs-on: ubuntu-latest
97
111
  environment:
98
112
  name: pypi
@@ -1,16 +1,19 @@
1
- name: Publish interactive demo
1
+ name: Publish docs site
2
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).
3
5
  on:
4
6
  push:
5
7
  branches: [main]
6
8
  paths:
9
+ - docs/site/**
7
10
  - docs/assets/sqlassert-demo.html
8
- - docs/site/index.html
9
- - .github/workflows/demo-pages.yml
11
+ - zensical.toml
12
+ - .github/workflows/pages.yml
10
13
  workflow_dispatch:
11
14
 
12
15
  concurrency:
13
- group: demo-pages
16
+ group: pages
14
17
 
15
18
  jobs:
16
19
  deploy:
@@ -24,12 +27,13 @@ jobs:
24
27
  url: ${{ steps.deployment.outputs.page_url }}
25
28
  steps:
26
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
27
36
  - uses: actions/configure-pages@v5
28
- - name: Prepare demo
29
- run: |
30
- mkdir _site
31
- cp docs/site/index.html _site/index.html
32
- cp docs/assets/sqlassert-demo.html _site/demo.html
33
37
  - uses: actions/upload-pages-artifact@v4
34
38
  with:
35
39
  path: _site
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  .vscode
2
3
  *egg-info
3
4
  build/
@@ -6,5 +7,7 @@ tmp
6
7
  papers/
7
8
  vendor/
8
9
  __pycache__/
9
- docs/issues/mkt/
10
- docs/issues/pvt/
10
+ /docs/issues/mkt
11
+ /docs/issues/pvt
12
+ /pvt/
13
+ _site/
@@ -20,7 +20,8 @@ Whenever a connection would have helped (a table with no `CREATE`, an unknown
20
20
  column type, an ambiguous column), emit a warning Diagnostic saying what is
21
21
  missing and how to supply it, and treat the affected facts as unknown; never
22
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.
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.
24
25
 
25
26
  ## Current, strict engines only
26
27
 
@@ -31,6 +32,16 @@ off), and no meaning for SQL the standard rejects but a flavor tolerates
31
32
  (a column neither grouped nor aggregated): make it opaque and warn
32
33
  `unsupported-construct`. Simpler code beats supporting outdated SQL.
33
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
+
34
45
  ## Where things are
35
46
 
36
47
  - Domain language: `CONTEXT.md`. Use its terms; it lists terms to avoid.
@@ -38,9 +49,10 @@ off), and no meaning for SQL the standard rejects but a flavor tolerates
38
49
  - Rule style: `sqlassert/rules/STYLEGUIDE.md`.
39
50
  - Test style: SQL cases in `tests/*.sqltest` (format in `tests/sqltest.py`;
40
51
  see "Tests" in `docs/implementation-conventions.md`).
41
- - Open work: `docs/issues/` (index in `docs/issues/README.md`). Marketing
52
+ - Open work: `docs/issues/` (list in `docs/issues/list.md`). Marketing
42
53
  work is in `docs/issues/mkt/`, client work in `docs/issues/pvt/`; both are
43
- gitignored and never committed.
54
+ gitignored and never committed. Before opening, working on or closing an
55
+ issue, read `docs/issues/README.md`.
44
56
  - Architecture decisions: `docs/adr/`.
45
57
 
46
58
  ## Testing workflow
@@ -22,29 +22,91 @@ 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
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
 
38
- **Float Equality**:
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**:
39
101
  An equality comparison (`=`, `<>`, `IS [NOT] DISTINCT FROM`, an IN list or
40
- subquery) with an operand of a known floating type, REAL, FLOAT or DOUBLE
41
- in any spelling (a Hazard): floats round, so comparing one for exact
42
- equality is wrong, against another float, an integer, a decimal or a
43
- literal (`x = 0.1`). Which values a float holds exactly, and how each
44
- dialect converts the other side, are no rule to rely on. An ordering
45
- (`<`, `>`) is none, and so is an operand whose type is unknown.
46
- _Avoid_: Lossy comparison, float comparison (an ordering is fine), precision
47
- loss, rounding comparison, implicit cast (that Hazard is text)
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
48
110
 
49
111
  **Exactly One Join Assertion**:
50
112
  An assertion that every row of a join's left-hand input matches exactly one
@@ -77,16 +139,17 @@ than no marker at all.
77
139
  _Avoid_: Assertion, Property Declaration, annotation, hint
78
140
 
79
141
  **Property**:
80
- A structural semantic statement about a relation or query construct. The same
81
- Property types are used in two ways: an Assertion wraps one as a query, while a
82
- Property Declaration lists one as accepted Knowledge. A public Analysis
83
- Function evaluates a Property.
84
- _Avoid_: Rule, flag
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
85
149
 
86
150
  **Analysis Function**:
87
- A computation over the semantic program that returns an Analysis Result. A
88
- public Analysis Function evaluates a Property; an internal one derives a value
89
- 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.
90
153
  _Avoid_: Rule, property
91
154
 
92
155
  **Analysis Result**:
@@ -96,8 +159,8 @@ and members rather than by a separate evidence object.
96
159
  _Avoid_: Proof, property
97
160
 
98
161
  **Result Value**:
99
- The computed value inside an Analysis Result. It can be a Boolean property
100
- answer or a derived value used only during analysis.
162
+ The computed value inside an Analysis Result: whether a Public or Private
163
+ Property holds, or another derived value.
101
164
  _Avoid_: Property, proof
102
165
 
103
166
  **Evidence**:
@@ -123,7 +186,7 @@ An explicit report that part of a SQL program could not be analyzed, such as an
123
186
  _Avoid_: Error, warning, validation failure, unknown
124
187
 
125
188
  **Connection Warning**:
126
- 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`), and 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). The last four are about the SQL itself, so `analyze_database` keeps them.
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).
127
190
 
128
191
  **Non-Null Elements**:
129
192
  A Property of composite columns (ARRAY, ROW, MAP): no element of a listed
@@ -227,7 +290,7 @@ database enum type, though a catalog's enum type could supply it as Knowledge.
227
290
  _Avoid_: Enum type, value set, check constraint
228
291
 
229
292
  **Equality Group**:
230
- 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) between known matching comparison types, 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.
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.
231
294
  _Avoid_: Equivalence class, alias set
232
295
 
233
296
  **Null Source**:
@@ -247,7 +310,9 @@ A place in the SQL text where a Property Marker can be written: right before a
247
310
  JOIN, right after the last token of a Select Expression (of the whole query,
248
311
  for a set operation: its last operand ends there too, so it has none), or
249
312
  right before a simple `CASE`. Every marker attaches at one; `suggest` names each site by its
250
- line and what it marks.
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).
251
316
  _Avoid_: Marker position, anchor
252
317
 
253
318
  **Rewrite**:
@@ -255,11 +320,14 @@ A rewrite of the SQL itself, at one Attachment Site, that a Proof shows leaves
255
320
  the program's result unchanged as a multiset: an outer join that cannot keep a
256
321
  padded row written as an inner join, a join that is redundant or only filters,
257
322
  a redundant `DISTINCT` or grouping column, an unused CTE. It guarantees the
258
- same rows; a column's type or precision may change, or its arithmetic
259
- overflow, which makes it a Rewrite with Caveat.
260
- Otherwise (same rows, same column types, no new error) it is a plain
261
- Rewrite, suggestion type `rewrite`. `suggest` ranks Rewrites before Rewrites
262
- with Caveat, those before markers to paste, and those before Hazards. Every
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
263
331
  Rewrite is made by its Rewrite Edits, and is offered only with them.
264
332
  _Avoid_: Improvement, optimization, lint, hint
265
333
 
@@ -273,18 +341,17 @@ edits, and the equivalence tests run exactly the SQL they make.
273
341
  _Avoid_: Patch, fix, rewritten query (for the edits themselves)
274
342
 
275
343
  **Rewrite with Caveat**:
276
- A Rewrite that keeps the rows but may change an output column's type,
277
- precision or overflow, its message naming the column and the risk
278
- (suggestion type `rewrite with caveat`): a `GROUP BY` whose groups are
279
- single rows, written as a projection, replaces `sum(x)` by `x` (DuckDB's
280
- HUGEINT sum becomes x's INTEGER, and `sum(x) + 1` as `x + 1` may overflow)
281
- and `avg(b)` of a BIGINT by `b` (exact, where avg's DOUBLE may round).
282
- sqlassert has no result-type model per dialect, so precision and type
283
- differences are always a caveat, never a refusal. A replacement whose value
284
- differs otherwise (`sum` of a BOOLEAN counts it) or whose type is unknown is
285
- no Rewrite.
286
- _Avoid_: Unsafe rewrite, approximate rewrite, lossy rewrite (the rows are
287
- the same)
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
288
355
 
289
356
  **Implied Condition**:
290
357
  A conjunct of a WHERE or ON that the other conjuncts and the input's facts
@@ -302,8 +369,13 @@ A place whose result the SQL leaves unspecified or likely wrong, with the
302
369
  failed Proof that would have pinned it: a Fan Trap or Chasm Trap, an unmarked
303
370
  join that may be many to many, a `LIMIT`
304
371
  that picks arbitrary rows among ties, a scalar subquery that may return more
305
- than one row, a join equality that casts, an exact equality of a float
306
- (a Float Equality), a query that never returns a row.
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).
307
379
  The SQL may be what its author meant. `suggest` lists Hazards last; the
308
380
  suggestion's type (`SuggestType`) is rewrite, rewrite with caveat, marker or
309
381
  hazard.
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: sqlassert
3
+ Version: 0.4.1
4
+ Summary: Asserts and static proofs for your SQL, without touching your data.
5
+ Author: Fred Israel
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/polvoazul/sqlassert
8
+ Project-URL: Documentation, https://polvoazul.github.io/sqlassert/
9
+ Project-URL: Issues, https://github.com/polvoazul/sqlassert/issues
10
+ Keywords: sql,static-analysis,linter,dbt,data-quality,join,cardinality,sqlglot
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: SQL
16
+ Classifier: Topic :: Database
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.13
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: case-conversion>=3.0.2
22
+ Requires-Dist: sqlglot<31,>=30.30
23
+ Provides-Extra: test
24
+ Requires-Dist: duckdb>=2.0; extra == "test"
25
+ Requires-Dist: hypothesis; extra == "test"
26
+ Requires-Dist: pytest; extra == "test"
27
+ Requires-Dist: pytest-xdist; extra == "test"
28
+ Provides-Extra: dev
29
+ Requires-Dist: ty>=0.0.104; extra == "dev"
30
+ Provides-Extra: docs
31
+ Requires-Dist: zensical>=0.1.4; extra == "docs"
32
+ Dynamic: license-file
33
+
34
+ # sqlassert
35
+
36
+ [![PyPI version](https://img.shields.io/pypi/v/sqlassert)](https://pypi.org/project/sqlassert/)
37
+ [![CI](https://github.com/polvoazul/sqlassert/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/polvoazul/sqlassert/actions/workflows/ci.yml)
38
+ [![MIT license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
39
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13%2B-blue)](https://pypi.org/project/sqlassert/)
40
+
41
+ **sqlassert adds asserts and static proofs to your SQL, without touching your data, to catch common mistakes before they ship.**
42
+
43
+ [![Open the interactive demo showing highlighted SQL and a Fan Trap finding](docs/assets/sqlassert-demo-preview.png)](https://polvoazul.github.io/sqlassert/demo.html)
44
+
45
+ [Open the interactive demo](https://polvoazul.github.io/sqlassert/demo.html)
46
+
47
+ Mark what a query must guarantee (this join never multiplies rows, this column is a key, this `CASE` covers every status) and sqlassert proves it from the SQL and schema alone. A proof holds for *any* data, not just the rows in the table today, and it runs in milliseconds in your test suite or CI, with no warehouse and no connection.
48
+
49
+ ```bash
50
+ pip install sqlassert
51
+ sqlassert suggest my_query.sql # what can already be proved, and what looks wrong
52
+ ```
53
+
54
+ Using dbt? [`sqlassert-dbt`](https://github.com/polvoazul/sqlassert/tree/main/integrations/dbt#readme) proves your `unique`, `not_null`, `accepted_values` and `relationships` tests from the compiled SQL and **skips the ones that can't fail**, so `dbt build` runs fewer warehouse queries.
55
+
56
+ _Alpha: the markers (`/**ASSERT ...**/`, `/**DECLARE ...**/`) are the stable contract; the Python API may change. Tested with DuckDB, PostgreSQL, MySQL, Snowflake, BigQuery, Databricks / Spark, Redshift and Trino SQL (see [Dialects](https://polvoazul.github.io/sqlassert/dialects/)); only DuckDB programs are checked by the soundness oracle, and only DuckDB and SQLite are high support: elsewhere some dialect facts are unprobed, so a proof can be wrong._
57
+
58
+ ## Pitfalls it catches
59
+
60
+ ### A join that silently multiplies rows
61
+
62
+ It works today because every user has one email row. Then someone adds a second one, and every downstream count doubles. Say what the join must do:
63
+
64
+ ```sql
65
+ create table users (id integer primary key, email varchar);
66
+ create table user_emails (user_id integer, email varchar);
67
+
68
+ select u.id, e.email
69
+ from users u
70
+ /**ASSERT MANY TO ONE**/ join user_emails e on e.user_id = u.id;
71
+ ```
72
+
73
+ ```console
74
+ $ sqlassert check join.sql
75
+ join.sql:6:1: error unproved-many-to-one-join: /**ASSERT MANY TO ONE**/ is not proved (UNKNOWN)
76
+ ```
77
+
78
+ Nothing makes `user_emails.user_id` unique, so the join may fan out, and `--explain` says exactly that: "No known unique set on this relation — user_emails AS e". Add the key (or a `GROUP BY`, `DISTINCT`, or `QUALIFY row_number() = 1`) and it is `PROVED`. From then on, a change that breaks it fails CI rather than corrupting a dashboard.
79
+
80
+ ### Fan traps: sums counted twice
81
+
82
+ Two one-to-many joins from the same row, then a `sum`: each order is counted once per payment.
83
+
84
+ ```sql
85
+ select c.id, sum(o.amount) as ordered, sum(p.amount) as paid
86
+ from customers c
87
+ join orders o on o.customer_id = c.id
88
+ join payments p on p.customer_id = c.id
89
+ group by c.id;
90
+ ```
91
+
92
+ ```console
93
+ $ sqlassert suggest revenue.sql
94
+ ...
95
+ low line 9 Root Select Fan trap SUM(o.amount) reads rows that JOIN payments AS p may repeat: the join is not proved to repeat rows of only one input (fan trap), so a value may be counted more than once
96
+ low line 9 Root Select Fan trap SUM(p.amount) reads rows that JOIN payments AS p may repeat: ...
97
+ ```
98
+
99
+ Chasm traps (`sum(c.credit)` over `customers JOIN orders`), scalar subqueries that can return two rows, and implicit casts in join keys are flagged the same way.
100
+
101
+ ### Joins that do nothing, and LIMITs that pick random rows
102
+
103
+ ```sql
104
+ select o.id, u.name
105
+ from orders o
106
+ left join users u on u.id = o.user_id -- user_id is NOT NULL REFERENCES users(id)
107
+ left join coupons c on c.id = o.coupon_id -- nothing from coupons is used
108
+ order by u.name
109
+ limit 10;
110
+ ```
111
+
112
+ ```console
113
+ $ sqlassert suggest orders.sql
114
+ rewrite line 7 LEFT JOIN users AS u INNER JOIN every left row matches exactly one right row, so the LEFT JOIN pads nothing: write JOIN
115
+ --- orders.sql
116
+ +++ orders.sql (rewritten)
117
+ @@ -5,5 +5,5 @@
118
+ select o.id, u.name
119
+ from orders o
120
+ -left join users u on u.id = o.user_id -- user_id is NOT NULL REFERENCES users(id)
121
+ +join users u on u.id = o.user_id -- user_id is NOT NULL REFERENCES users(id)
122
+ left join coupons c on c.id = o.coupon_id -- nothing from coupons is used
123
+ order by u.name
124
+ rewrite line 8 LEFT JOIN coupons AS c Redundant Join at most one match per row and no column of coupons AS c is used outside its ON: delete the join
125
+ --- orders.sql
126
+ +++ orders.sql (rewritten)
127
+ @@ -6,5 +6,5 @@
128
+ from orders o
129
+ left join users u on u.id = o.user_id -- user_id is NOT NULL REFERENCES users(id)
130
+ -left join coupons c on c.id = o.coupon_id -- nothing from coupons is used
131
+ +-- nothing from coupons is used
132
+ order by u.name
133
+ limit 10;
134
+ marker line 7 LEFT JOIN users AS u Exactly One Join /**ASSERT EXACTLY ONE**/
135
+ ...
136
+ hazard line 10 Root Select Arbitrary LIMIT the ORDER BY does not determine ('id'), so rows tied on it come in an arbitrary order and LIMIT may keep different rows on each run: order by a key as well
137
+ ```
138
+
139
+ Every rewrite is backed by a proof that it leaves the result unchanged, row for row, and comes with the exact diff that makes it; comments and markers in the text it replaces are kept. `--annotate` pastes the suggested markers into the file.
140
+
141
+ ### A CASE that forgets the new status
142
+
143
+ ```sql
144
+ with o as (
145
+ select * from orders
146
+ /**DECLARE ENUM(status IN ('new', 'paid', 'void', 'refunded'))**/
147
+ )
148
+ select id,
149
+ /**ASSERT EXHAUSTIVE**/ case status when 'new' then 'open' when 'paid' then 'closed' when 'void' then 'closed' end as state
150
+ from o;
151
+ ```
152
+
153
+ ```console
154
+ $ sqlassert check orders.sql --explain
155
+ orders.sql:7:3: error unproved-exhaustive: /**ASSERT EXHAUSTIVE**/ is not proved (UNKNOWN)
156
+ #1 UNKNOWN: exhaustive_case — CASE status WHEN 'new' THEN 'open' ...
157
+ #2 UNKNOWN: status may be 'refunded', which no WHEN arm lists
158
+ ```
159
+
160
+ Without the marker, `refunded` orders would quietly get a NULL `state`.
161
+
162
+ ### dbt tests that scan the warehouse for nothing
163
+
164
+ ```console
165
+ $ sqlassert-dbt build . -- --target prod
166
+ Proved statically (a test here can be skipped):
167
+ models/schema.yml unique_stg_customers_customer_id (test on stg_customers)
168
+ ...
169
+ ```
170
+
171
+ Proved tests are passed to `dbt build` as `--exclude`, so they never run. See [sqlassert-dbt](https://github.com/polvoazul/sqlassert/tree/main/integrations/dbt#readme).
172
+
173
+ ## What it proves
174
+
175
+ | Assertion | Marker | Guards against | `DECLARE` form |
176
+ |---|---|---|---|
177
+ | [Join cardinality](https://polvoazul.github.io/sqlassert/markers/#join-cardinality) | `UNIQUE`, `MANY TO ONE`, `ONE TO MANY`, `ONE TO ONE` before a join | row multiplication | – |
178
+ | [Exactly One Join](https://polvoazul.github.io/sqlassert/markers/#exactly-one-join) | `EXACTLY ONE` before a join | rows multiplied *or dropped*; a LEFT JOIN that pads | – |
179
+ | [Unique Set](https://polvoazul.github.io/sqlassert/markers/#unique-set-and-non-null-unique-set) | `UNIQUE(cols)`, `NOT NULL UNIQUE(cols)`, `PRIMARY KEY(cols)` | duplicate keys, wrong grain | yes |
180
+ | [Not Null](https://polvoazul.github.io/sqlassert/markers/#not-null) | `NOT NULL(cols)` | NULLs from outer joins and nullable sources | yes |
181
+ | [Not Null Elements](https://polvoazul.github.io/sqlassert/markers/#not-null-elements) | `NOT NULL ELEMENTS(cols)` | NULLs inside arrays, rows and maps | yes |
182
+ | [Foreign Key](https://polvoazul.github.io/sqlassert/markers/#foreign-key) | `FOREIGN KEY(cols) REFERENCES rel(cols)` | orphaned rows | yes |
183
+ | [Functional Dependency](https://polvoazul.github.io/sqlassert/markers/#functional-dependency) | `DETERMINES(a -> b)` | a value that should follow from a key but doesn't | yes |
184
+ | [Enum](https://polvoazul.github.io/sqlassert/markers/#enum) | `ENUM(col IN (...))` | unexpected values | yes |
185
+ | [Exhaustive CASE](https://polvoazul.github.io/sqlassert/markers/#exhaustive-case) | `EXHAUSTIVE` before a `CASE` | a value no `WHEN` arm handles | – |
186
+
187
+ Every marker is a SQL comment (`/**ASSERT ...**/`), so annotated SQL still runs unchanged on your database.
188
+
189
+ | Tool | What it does |
190
+ |---|---|
191
+ | [`analyze(sql)`](https://polvoazul.github.io/sqlassert/python/) | Python API: prove a SQL Program's markers from its `CREATE` statements, in your test suite. |
192
+ | [`analyze_database`](https://polvoazul.github.io/sqlassert/python/) | The same, with tables, keys and views read from a live catalog (metadata only, never rows). |
193
+ | [`sqlassert check`](https://polvoazul.github.io/sqlassert/cli/#sqlassert-check) | CLI for CI: text, JSON, SARIF and GitHub annotation output, `pyproject.toml` config. |
194
+ | [`sqlassert suggest`](https://polvoazul.github.io/sqlassert/cli/#sqlassert-suggest) | Lists provable markers, proved rewrites, and hazards (fan traps, chasm traps, arbitrary LIMIT, ...). |
195
+ | [`sqlassert-dbt`](https://github.com/polvoazul/sqlassert/tree/main/integrations/dbt#readme) | Checks a dbt project from its manifest and skips the tests the SQL proves. |
196
+
197
+ | Dialect | Key constraints | Catalog fetcher | Support |
198
+ |---|---|---|---|
199
+ | DuckDB | enforced | yes | high, plus the soundness oracle |
200
+ | PostgreSQL | enforced | yes | low |
201
+ | MySQL 8.4+ (strict `sql_mode`) | enforced | yes | low |
202
+ | Snowflake | unenforced, `RELY` | yes | low |
203
+ | BigQuery | unenforced | yes | low |
204
+ | Databricks / Spark | unenforced, `RELY` | yes | low |
205
+ | Redshift | unenforced | yes | low |
206
+ | Trino | none | yes (NOT NULL only) | low |
207
+
208
+ A low-support dialect has dialect facts written from memory and not yet
209
+ probed on the engine, so its analysis can contain mistakes: a PROVED
210
+ assertion there can be wrong. A dialect with no such fact is high support
211
+ (DuckDB, SQLite); see [Support levels](https://github.com/polvoazul/sqlassert/blob/main/docs/dialects.md#support-levels).
212
+
213
+ Unenforced keys are trusted as declarations by default; `trust_unenforced_keys=False` keeps only those marked `RELY` (see [Dialects](https://polvoazul.github.io/sqlassert/dialects/)).
214
+
215
+ ## Documentation
216
+
217
+ The full reference is at **[polvoazul.github.io/sqlassert](https://polvoazul.github.io/sqlassert/)**:
218
+
219
+ - [Quickstart](https://polvoazul.github.io/sqlassert/quickstart/): install, a first marker, `check` and `suggest`.
220
+ - [Markers](https://polvoazul.github.io/sqlassert/markers/): every `ASSERT` and `DECLARE`, what proves it, and what it guards against.
221
+ - [CLI](https://polvoazul.github.io/sqlassert/cli/): `check` for CI (exit codes, output formats, configuration), `suggest`, rewrites and hazards.
222
+ - [Python API](https://polvoazul.github.io/sqlassert/python/): `analyze`, `analyze_database` and catalog fetchers.
223
+ - [For dbt users](https://polvoazul.github.io/sqlassert/dbt/): `sqlassert-dbt check`, `build` and `suggest`.
224
+ - [Dialects](https://polvoazul.github.io/sqlassert/dialects/): what each engine is assumed to do.
225
+ - [Diagnostic codes](https://polvoazul.github.io/sqlassert/codes/): what each code means and how to fix it.
226
+ - [How proofs work](https://polvoazul.github.io/sqlassert/proofs/): proofs, not data checks.
227
+
228
+ ## Roadmap
229
+
230
+ Open work is tracked as one file per issue in [`docs/issues/`](https://github.com/polvoazul/sqlassert/blob/main/docs/issues/list.md).
231
+
232
+ ## Citation
233
+
234
+ If you use sqlassert in published research, please cite the version you used.
235
+ See [CITATION.cff](CITATION.cff) for citation details.