sqlassert 0.3.1__py3-none-any.whl → 0.3.3__py3-none-any.whl

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/suggest.py CHANGED
@@ -1,9 +1,10 @@
1
1
  """Suggest the Property Markers sqlassert can prove for a SQL Program.
2
2
 
3
- Three levels of suggestion. High: Improvements, rewrites of the SQL itself
4
- that a proof shows leave its result unchanged (`improvements.py`). Mid:
5
- markers that lock in what is provable but not asserted. Low: Smells, places
6
- whose result the SQL leaves unspecified (`smells.py`).
3
+ Four types of suggestion (`SuggestType`). Rewrites: changes to the SQL
4
+ itself that a proof shows leave its result unchanged (`rewrites.py`), each
5
+ made by exact edits (`edits.py`), with a caveat when a column's type or
6
+ precision may change. Markers: what is provable but not asserted, to lock in. Hazards: places
7
+ whose result the SQL leaves unspecified (`hazards.py`).
7
8
 
8
9
  Marker candidates are generated mechanically from the Program IR, one
9
10
  Attachment Site at a time: every markable JOIN may be a Unique Join (or
@@ -16,7 +17,8 @@ callers that judge candidates by other means.
16
17
 
17
18
  from __future__ import annotations
18
19
 
19
- from collections.abc import Iterable, Iterator
20
+ from collections.abc import Callable, Iterable, Iterator
21
+ from contextlib import AbstractContextManager
20
22
  from dataclasses import dataclass, fields
21
23
  from decimal import Decimal
22
24
  from itertools import combinations
@@ -27,9 +29,10 @@ from sqlglot import exp
27
29
  from sqlassert import diagnostics as diag
28
30
  from sqlassert import ir
29
31
  from sqlassert.diagnostics import Diagnostic
30
- from sqlassert.improvements import Improvement, Level, Rewrite, improvements
31
- from sqlassert.ir.convert import IrParser
32
- from sqlassert.smells import Concern, Smell, smells
32
+ from sqlassert.edits import Edit
33
+ from sqlassert.rewrites import Rewrite, SuggestType, RewriteKind, rewrites
34
+ from sqlassert.ir.convert import IrConversionResult, IrParser
35
+ from sqlassert.hazards import Concern, Hazard, hazards
33
36
  from sqlassert.main import DEFAULT_DIALECT
34
37
  from sqlassert.properties import (
35
38
  EnumeratedDomain, ExactlyOneJoin, ExhaustiveCase, ManyToOneJoin, NonNullColumn, NonNullColumns, NonNullUniqueSet,
@@ -38,7 +41,7 @@ from sqlassert.properties import (
38
41
  from sqlassert.python_engine import Arena, Engine, Result
39
42
  from sqlassert.provenance import AttachmentSite
40
43
  from sqlassert.rules.domain import _domain
41
- from sqlassert.sql_parse import SqlParser
44
+ from sqlassert.sql_parse import ParsedProgram, SqlParser
42
45
 
43
46
  DEFAULT_MAX_SIZE = 3
44
47
 
@@ -48,8 +51,8 @@ DEFAULT_MAX_SIZE = 3
48
51
  MAX_ENUM_VALUES = 10
49
52
 
50
53
  __all__ = [
51
- "Candidate", "Concern", "Improvement", "Level", "Rewrite", "Smell", "Suggestion", "SuggestionReport", "annotate",
52
- "candidates", "suggest",
54
+ "Candidate", "Concern", "Edit", "Rewrite", "SuggestType", "RewriteKind", "Hazard", "Suggester", "Suggestion", "SuggestionReport",
55
+ "annotate", "candidates", "suggest", "suggest_parsed",
53
56
  ]
54
57
 
55
58
 
@@ -70,20 +73,25 @@ class Suggestion:
70
73
  property: Property
71
74
  marker: str
72
75
  evidence: Result[bool]
73
- level: ClassVar[Level] = Level.MID
76
+ suggest_type: ClassVar[SuggestType] = SuggestType.MARKER
77
+
78
+ @property
79
+ def kind(self) -> str:
80
+ """The Property's name, as a listing shows it."""
81
+ return _KINDS[type(self.property)]
74
82
 
75
83
 
76
84
  @dataclass(frozen=True)
77
85
  class SuggestionReport:
78
- """`improvements` (High) rewrite the SQL; `suggestions` (Mid) are markers
79
- to paste; `smells` (Low) point at results the SQL leaves unspecified."""
86
+ """`rewrites` rewrite the SQL, some with a caveat; `suggestions` are
87
+ markers to paste; `hazards` point at results the SQL leaves unspecified."""
80
88
 
81
89
  sql: str
82
90
  suggestions: tuple[Suggestion, ...] = ()
83
91
  diagnostics: tuple[Diagnostic, ...] = ()
84
- improvements: tuple[Improvement, ...] = ()
92
+ rewrites: tuple[Rewrite, ...] = ()
85
93
  warnings: tuple[Diagnostic, ...] = ()
86
- smells: tuple[Smell, ...] = ()
94
+ hazards: tuple[Hazard, ...] = ()
87
95
 
88
96
  def annotated(self, chosen: Iterable[Suggestion] | None = None) -> str:
89
97
  """The SQL with the chosen suggestions' markers pasted in (all by default)."""
@@ -108,7 +116,7 @@ def suggest(
108
116
  sql: str, *, dialect: str = DEFAULT_DIALECT, max_size: int = DEFAULT_MAX_SIZE, trust_unenforced_keys: bool = True,
109
117
  ) -> SuggestionReport:
110
118
  """Every Property sqlassert can prove about `sql`, as markers to paste,
111
- and every Improvement a proof justifies.
119
+ and every Rewrite a proof justifies.
112
120
 
113
121
  Per Select Expression: each minimal Unique Set up to `max_size` columns,
114
122
  as a Non-Null Unique Set when that also holds, plus one minimal set found
@@ -120,28 +128,83 @@ def suggest(
120
128
  Properties the SQL already asserts or declares are left out.
121
129
  """
122
130
  ast = SqlParser(dialect).parse(sql)
123
- conversion = IrParser(dialect, trust_unenforced_keys).parse(ast)
124
- program, diagnostics = conversion.program, ast.diagnostics + conversion.diagnostics
125
- if any(diagnostic.code in _BLOCKING for diagnostic in diagnostics):
126
- return SuggestionReport(sql, (), diagnostics, warnings=conversion.warnings)
127
- present = (*program.declarations, *(assertion.property for assertion in program.assertions))
128
- marked_non_null = {
129
- column
130
- for item in present
131
- for column in (
132
- (item.column,) if isinstance(item, NonNullColumn) else item.columns if isinstance(item, NonNullColumns) else ()
133
- )
134
- }
135
- marked_joins = {item.join for item in present if isinstance(item, _JOIN_PROPERTIES)}
136
- marked_cases = {item.case for item in present if isinstance(item, ExhaustiveCase)}
137
- reachable = set(program.nodes())
138
- suggestions: list[Suggestion] = []
139
- with Engine().session(program, conversion.knowledge) as arena:
140
- found = improvements(ast, program, arena, dialect)
141
- concerns = smells(ast, program, arena)
142
- for site, relation in program.attachment_sites:
131
+ return suggest_parsed(sql, ast, IrParser(dialect, trust_unenforced_keys).parse(ast), dialect=dialect, max_size=max_size)
132
+
133
+
134
+ def suggest_parsed(
135
+ sql: str, ast: ParsedProgram, conversion: IrConversionResult, *, dialect: str = DEFAULT_DIALECT,
136
+ max_size: int = DEFAULT_MAX_SIZE,
137
+ ) -> SuggestionReport:
138
+ """`suggest` of a Program already parsed and lowered: for a caller that
139
+ adds Property Declarations to `conversion.program` before proving."""
140
+ with Suggester(sql, ast, conversion, dialect=dialect, max_size=max_size) as suggester:
141
+ return suggester.suggest()
142
+
143
+
144
+ class Suggester:
145
+ """`suggest` over one lowered Program, one part at a time, for a caller
146
+ that wants each part as soon as it is found: proofs are memoized across
147
+ parts, and Rewrites and Hazards are found once, for every site
148
+ `sites` accepts (all by default). Use it as a context manager: it holds
149
+ the Program's analysis session."""
150
+
151
+ def __init__(
152
+ self, sql: str, ast: ParsedProgram, conversion: IrConversionResult, *, dialect: str = DEFAULT_DIALECT,
153
+ max_size: int = DEFAULT_MAX_SIZE, sites: Callable[[AttachmentSite], bool] | None = None,
154
+ ):
155
+ self.sql, self.ast, self.conversion, self.dialect, self.max_size = sql, ast, conversion, dialect, max_size
156
+ self.sites = sites or (lambda site: True)
157
+ self.program = conversion.program
158
+ self.diagnostics = ast.diagnostics + conversion.diagnostics
159
+ self.blocked = any(diagnostic.code in _BLOCKING for diagnostic in self.diagnostics)
160
+ present = (*self.program.declarations, *(assertion.property for assertion in self.program.assertions))
161
+ self.marked = {_identity(item) for item in present}
162
+ self.marked_non_null = {
163
+ column
164
+ for item in present
165
+ for column in (
166
+ (item.column,) if isinstance(item, NonNullColumn) else item.columns if isinstance(item, NonNullColumns) else ()
167
+ )
168
+ }
169
+ self.marked_joins = {item.join for item in present if isinstance(item, _JOIN_PROPERTIES)}
170
+ self.marked_cases = {item.case for item in present if isinstance(item, ExhaustiveCase)}
171
+ self.reachable = set(self.program.nodes())
172
+ self._session: AbstractContextManager[Arena] | None = None
173
+ self._arena: Arena | None = None
174
+ self._rewrites: list[Rewrite] = []
175
+ self._hazards: list[Hazard] = []
176
+
177
+ def __enter__(self) -> Suggester:
178
+ self._session = Engine().session(self.program, self.conversion.knowledge)
179
+ self._arena = self._session.__enter__()
180
+ try:
181
+ if not self.blocked:
182
+ self._rewrites = rewrites(self.ast, self.program, self._arena, self.dialect, wanted=self.sites)
183
+ self._hazards = hazards(self.ast, self.program, self._arena, self.dialect, wanted=self.sites)
184
+ except BaseException as error:
185
+ self.__exit__(type(error), error, error.__traceback__)
186
+ raise
187
+ return self
188
+
189
+ def __exit__(self, *exc: object) -> None:
190
+ assert self._session is not None
191
+ self._session.__exit__(*exc) # ty: ignore[invalid-argument-type]
192
+ self._arena = None
193
+
194
+ def suggest(self, sites: Callable[[AttachmentSite], bool] | None = None) -> SuggestionReport:
195
+ """What is found at the sites both `sites` and the Suggester's accept."""
196
+ arena = self._arena
197
+ assert arena is not None, "use the Suggester as a context manager"
198
+ wanted = sites or (lambda site: True)
199
+ if self.blocked:
200
+ return SuggestionReport(self.sql, (), self.diagnostics, warnings=self.conversion.warnings)
201
+ suggestions: list[Suggestion] = []
202
+ dialect, reachable = self.dialect, self.reachable
203
+ for site, relation in self.program.attachment_sites:
204
+ if not (self.sites(site) and wanted(site)):
205
+ continue
143
206
  match relation:
144
- case ir.Join() if not site.trailing and relation not in marked_joins and relation in reachable:
207
+ case ir.Join() if not site.trailing and relation not in self.marked_joins and relation in reachable:
145
208
  # The strongest proved form. Not many to many is implied by each
146
209
  # cardinality, so it is never suggested on its own; a semi or
147
210
  # anti join outputs no right rows, so no cardinality applies.
@@ -153,21 +216,37 @@ def suggest(
153
216
  # Already marked, or unreachable: lowered inside a Select that is
154
217
  # opaque as a whole (one with HAVING, say), so nothing is known about it.
155
218
  pass
156
- case ir.SimpleCase() if relation not in marked_cases and relation in reachable and _markable(relation):
219
+ case ir.SimpleCase() if relation not in self.marked_cases and relation in reachable and _markable(relation):
157
220
  suggestions.extend(_proved(arena, site, ExhaustiveCase(case=relation), (), dialect))
158
221
  case ir.SimpleCase():
159
222
  pass # Already marked, unreachable, or with a WHEN no marker allows.
160
- case _:
161
- suggestions.extend(_select_suggestions(arena, site, relation, max_size, marked_non_null, dialect))
162
- marked = {_identity(item) for item in present}
163
- kept = tuple(
164
- sorted(
165
- (suggestion for suggestion in suggestions if _identity(suggestion.property) not in marked),
166
- key=lambda suggestion: suggestion.site.offset,
223
+ case _ if relation in reachable:
224
+ suggestions.extend(_select_suggestions(arena, site, relation, self.max_size, self.marked_non_null, dialect))
225
+ kept = tuple(
226
+ sorted(
227
+ (suggestion for suggestion in suggestions if _identity(suggestion.property) not in self.marked),
228
+ key=lambda suggestion: suggestion.site.offset,
229
+ )
167
230
  )
168
- )
169
- return SuggestionReport(sql, kept, diagnostics, tuple(found), conversion.warnings, tuple(concerns))
231
+ return SuggestionReport(
232
+ self.sql, kept, self.diagnostics, tuple(item for item in self._rewrites if wanted(item.site)),
233
+ self.conversion.warnings, tuple(item for item in self._hazards if wanted(item.site)),
234
+ )
235
+
170
236
 
237
+ # How each suggested Property reads in a listing.
238
+ _KINDS: dict[type[Property], str] = {
239
+ ExactlyOneJoin: "Exactly One Join",
240
+ OneToOneJoin: "One To One Join",
241
+ ManyToOneJoin: "Many To One Join",
242
+ OneToManyJoin: "One To Many Join",
243
+ UniqueJoin: "Unique Join",
244
+ UniqueSet: "Unique Set",
245
+ NonNullUniqueSet: "Non-Null Unique Set",
246
+ NonNullColumns: "Not Null",
247
+ EnumeratedDomain: "Enumerated Domain",
248
+ ExhaustiveCase: "Exhaustive Case",
249
+ }
171
250
 
172
251
  # The join Properties, strongest first.
173
252
  _JOIN_PROPERTIES = (ExactlyOneJoin, OneToOneJoin, ManyToOneJoin, OneToManyJoin, UniqueJoin)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlassert
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Asserts and static proofs for your SQL, without touching your data.
5
5
  Author: Fred Israel
6
6
  License-Expression: MIT
@@ -25,13 +25,22 @@ Requires-Dist: hypothesis; extra == "test"
25
25
  Requires-Dist: pytest; extra == "test"
26
26
  Requires-Dist: pytest-xdist; extra == "test"
27
27
  Provides-Extra: dev
28
- Requires-Dist: ty; extra == "dev"
28
+ Requires-Dist: ty>=0.0.104; extra == "dev"
29
29
  Dynamic: license-file
30
30
 
31
31
  # sqlassert
32
32
 
33
+ [![PyPI version](https://img.shields.io/pypi/v/sqlassert)](https://pypi.org/project/sqlassert/)
34
+ [![CI](https://github.com/polvoazul/sqlassert/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/polvoazul/sqlassert/actions/workflows/ci.yml)
35
+ [![MIT license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
36
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13%2B-blue)](https://pypi.org/project/sqlassert/)
37
+
33
38
  **sqlassert adds asserts and static proofs to your SQL, without touching your data, to catch common mistakes before they ship.**
34
39
 
40
+ [![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)
41
+
42
+ [Open the interactive demo](https://polvoazul.github.io/sqlassert/demo.html)
43
+
35
44
  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.
36
45
 
37
46
  ```bash
@@ -99,14 +108,32 @@ limit 10;
99
108
 
100
109
  ```console
101
110
  $ sqlassert suggest orders.sql
102
- high 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
103
- high 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
104
- mid line 7 LEFT JOIN users AS u Exactly One Join /**ASSERT EXACTLY ONE**/
111
+ 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
112
+ --- orders.sql
113
+ +++ orders.sql (rewritten)
114
+ @@ -5,5 +5,5 @@
115
+ select o.id, u.name
116
+ from orders o
117
+ -left join users u on u.id = o.user_id -- user_id is NOT NULL REFERENCES users(id)
118
+ +join users u on u.id = o.user_id -- user_id is NOT NULL REFERENCES users(id)
119
+ left join coupons c on c.id = o.coupon_id -- nothing from coupons is used
120
+ order by u.name
121
+ 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
122
+ --- orders.sql
123
+ +++ orders.sql (rewritten)
124
+ @@ -6,5 +6,5 @@
125
+ from orders o
126
+ left join users u on u.id = o.user_id -- user_id is NOT NULL REFERENCES users(id)
127
+ -left join coupons c on c.id = o.coupon_id -- nothing from coupons is used
128
+ +-- nothing from coupons is used
129
+ order by u.name
130
+ limit 10;
131
+ marker line 7 LEFT JOIN users AS u Exactly One Join /**ASSERT EXACTLY ONE**/
105
132
  ...
106
- low 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
133
+ 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
107
134
  ```
108
135
 
109
- Every `high` rewrite is backed by a proof that it leaves the result unchanged, row for row. `--annotate` pastes the suggested markers into the file.
136
+ 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.
110
137
 
111
138
  ### A CASE that forgets the new status
112
139
 
@@ -161,7 +188,7 @@ Every marker is a SQL comment (`/**ASSERT ...**/`), so annotated SQL still runs
161
188
  | [`analyze(sql)`](#usage) | Python API: prove a SQL Program's markers from its `CREATE` statements, in your test suite. |
162
189
  | [`analyze_database`](#usage) | The same, with tables, keys and views read from a live catalog (metadata only, never rows). |
163
190
  | [`sqlassert check`](#checking-in-ci) | CLI for CI: text, JSON, SARIF and GitHub annotation output, `pyproject.toml` config. |
164
- | [`sqlassert suggest`](#suggesting-markers) | Lists provable markers, proved rewrites, and smells (fan traps, chasm traps, arbitrary LIMIT, ...). |
191
+ | [`sqlassert suggest`](#suggesting-markers) | Lists provable markers, proved rewrites, and hazards (fan traps, chasm traps, arbitrary LIMIT, ...). |
165
192
  | [`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. |
166
193
 
167
194
  | Dialect | Key constraints | Catalog fetcher | Dialect facts certified on a real engine |
@@ -222,7 +249,7 @@ where id > 0
222
249
  select * from active_users;
223
250
  ```
224
251
 
225
- The trailing marker applies to the relation produced by that Select Expression. `/**ASSERT NOT NULL UNIQUE(id)**/` asserts that `(id)` is a specific non-null Unique Set of `active_users`; `/**ASSERT UNIQUE(email)**/` would assert nullable-tolerant uniqueness instead. The assertion is proved from the SQL Program, not trusted as a declaration. If it cannot be proved, its outcome is `UNKNOWN`.
252
+ The trailing marker applies to the relation produced by that Select Expression. After the last token of a query with `UNION`, `INTERSECT` or `EXCEPT` (its `ORDER BY` and `LIMIT` included), it applies to the whole query; to mark its last operand alone, put that operand in parentheses. A marker between two operands applies to the one before it. `/**ASSERT NOT NULL UNIQUE(id)**/` asserts that `(id)` is a specific non-null Unique Set of `active_users`; `/**ASSERT UNIQUE(email)**/` would assert nullable-tolerant uniqueness instead. The assertion is proved from the SQL Program, not trusted as a declaration. If it cannot be proved, its outcome is `UNKNOWN`.
226
253
 
227
254
  Unique Set Assertions can be attached to a Root Select, view, CTE, or FROM subquery. A proved assertion on a named relation is also available to later statements in the same SQL Program.
228
255
 
@@ -246,9 +273,9 @@ with tagged as (select id, tags, old_tags from posts /**DECLARE NOT NULL ELEMENT
246
273
  select id, tags <> old_tags as retagged from tagged /**ASSERT NOT NULL(retagged)**/
247
274
  ```
248
275
 
249
- A column of unknown type is taken to be a scalar, not a composite. A
250
- constructor (`ARRAY[...]`, `ROW(...)`) is not modelled, so a comparison with
251
- one is never proved non-null.
276
+ If an operand's type is unknown, a comparison may require evidence that
277
+ its elements are non-null. Declare the source type or supply a catalog
278
+ connection to resolve it.
252
279
 
253
280
  ### Foreign Key
254
281
 
@@ -274,7 +301,7 @@ Nulls follow SQL's `MATCH SIMPLE`: a row with a null in any referencing column i
274
301
 
275
302
  `LIMIT` preserves facts about the rows it retains, including outgoing Foreign Keys, uniqueness, non-nullness, and Enumerated Domains. It may remove a required referenced row, so coverage onto its input does not establish coverage onto its result. The same boundary applies to `OFFSET`. A hard limit of at most one row also proves uniqueness without an input key.
276
303
 
277
- Equality Groups merge columns only when their declared comparison types are known and match, without collation. Mixed or unknown types leave value propagation unproved, even when SQL would compare them using implicit casts.
304
+ Equality Groups merge columns only when their declared comparison types are known and match. Mixed or unknown types leave value propagation unproved, even when SQL would compare them using implicit casts.
278
305
 
279
306
  `/**DECLARE FOREIGN KEY(...) REFERENCES relation(...)**/` states the coverage as trusted evidence (`Declared ReferentialCoverage` in explanations); it never vouches for the referenced Unique Set, which is still proved separately. A marker naming a column the referenced relation does not have is reported as `unknown-referenced-column`.
280
307
 
@@ -321,7 +348,7 @@ Dependencies come from keys, equalities and constants in `WHERE` and `ON`, group
321
348
 
322
349
  ### Enum
323
350
 
324
- `/**ASSERT ENUM(status IN ('new', 'paid'))**/` proves that every non-null value of `status` is one of the listed values. NULL is never in the set: `NOT NULL` governs it separately. One marker names one column, and lists distinct, non-null string, numeric, and boolean literals, which may be mixed: `/**ASSERT ENUM(priority IN (1, 2, 3))**/`, `/**DECLARE ENUM(active IN (TRUE))**/`. Anything else -- `NULL`, an empty list, a repeated value, `DATE '2020-01-01'`, a column, an expression -- is reported as a malformed marker.
351
+ `/**ASSERT ENUM(status IN ('new', 'paid'))**/` proves that every non-null value of `status` is one of the listed values. NULL is never in the set: `NOT NULL` governs it separately. So a column that is always NULL, like `CAST(NULL AS INTEGER) + 1`, satisfies every ENUM; the proof then warns `always-null-column`, as does any proved `UNIQUE`, `DETERMINES` determinant, `FOREIGN KEY`, `NOT NULL ELEMENTS` or `EXHAUSTIVE` operand that holds only because a column it names is always NULL. One marker names one column, and lists distinct, non-null string, numeric, and boolean literals, which may be mixed: `/**ASSERT ENUM(priority IN (1, 2, 3))**/`, `/**DECLARE ENUM(active IN (TRUE))**/`. Anything else -- `NULL`, an empty list, a repeated value, `DATE '2020-01-01'`, a column, an expression -- is reported as a malformed marker.
325
352
 
326
353
  ```sql
327
354
  with o as (
@@ -334,7 +361,7 @@ select status from o where status <> 'void' and status in ('new', 'paid')
334
361
 
335
362
  Domains come from `DECLARE ENUM` and external Knowledge, literals, `coalesce` of enumerated arguments, and simple `CASE` expressions (see below), and follow pass-through and renamed columns through filters, joins, aliases, grouping keys, `DISTINCT`, views, CTEs, and subqueries. A `WHERE` or inner-join `ON` conjunct `status = 'paid'` or `status IN ('new', 'paid')` narrows it, as does an outer join's `ON` on the side it pads. A domain crosses equalities: after `WHERE a = b` (or an inner-join `ON a = b`), `b`'s domain is `a`'s intersected with its own. An asserted set larger than the known domain is proved; an `UNKNOWN` explanation lists each possible value the assertion does not cover, such as "status may be 'void', which the assertion does not cover". A declaration does not claim that every listed value occurs. `UNION` columns, aggregates other than grouping keys, and other computed expressions are not enumerated.
336
363
 
337
- A value keeps its SQL type: numeric `1`, string `'1'`, and `TRUE` are three values, and none covers another. A number is identified by how it is written, because that is its SQL type: `007` is `7`, but `1.0` (a decimal) and `1e0` (a double) are not `1`, so asserting `ENUM(n IN (1))` of a column known to be `1.0` is `UNKNOWN`. Narrowing is more careful than identity: SQL compares a column with a literal after implicit casts, so one value can equal two different literals -- a `FLOAT` equals both `0.1` and `0.100000001`, a `VARCHAR` `'1.4'` equals both `1` and `1.4`, and an `INTEGER` equals both `1` and `'1'`. Domains therefore never lose a value that might equal one on the other side. Distinct strings, too, can equal one value -- an `INTEGER` equals `'01'` and `'1'`, a `VARCHAR COLLATE NOCASE` equals `'a'` and `'A'` -- so they narrow each other only on a column declared `VARCHAR` or `TEXT` compared by identity: with no `COLLATE`, in DuckDB or PostgreSQL (whose default collation is binary). A column of unknown type is not narrowed that way. A MySQL `ENUM` column's domain is its members without trailing spaces, as MySQL stores them (under its default strict `sql_mode`).
364
+ A value keeps its SQL type: numeric `1`, string `'1'`, and `TRUE` are three values, and none covers another. A number is identified by how it is written, because that is its SQL type: `007` is `7`, but `1.0` (a decimal) and `1e0` (a double) are not `1`, so asserting `ENUM(n IN (1))` of a column known to be `1.0` is `UNKNOWN`. Narrowing is more careful than identity: SQL compares a column with a literal after implicit casts, so one value can equal two different literals -- a `FLOAT` equals both `0.1` and `0.100000001`, a `VARCHAR` `'1.4'` equals both `1` and `1.4`, and an `INTEGER` equals both `1` and `'1'`. Domains therefore never lose a value that might equal one on the other side. Distinct strings, too, can equal one value -- an `INTEGER` equals `'01'` and `'1'`, a MySQL `VARCHAR` equals `'a'` and `'A'` -- so they narrow each other only on a column declared `VARCHAR` or `TEXT` compared by identity: in DuckDB, PostgreSQL or Trino (whose default collation is binary). A column of unknown type is not narrowed that way. A MySQL `ENUM` column's domain is its members without trailing spaces, as MySQL stores them (under its default strict `sql_mode`).
338
365
 
339
366
  ### Exhaustive CASE
340
367
 
@@ -477,27 +504,36 @@ Pass `dialect=` (a SQLGlot dialect name) to `analyze`, `analyze_database` and
477
504
  declared `NOT ENFORCED` or `DEFERRABLE`, a MySQL column-level `REFERENCES`
478
505
  (ignored before MySQL 9.0), a foreign key of a MySQL table whose `ENGINE`
479
506
  does not enforce them, and SQLite foreign keys.
480
- - **Text.** `VARCHAR` and `TEXT` with no `COLLATE` are taken to compare by
481
- identity in DuckDB, PostgreSQL and Trino, whose shipped default collation is
482
- binary (Trino has no collations); a setting that changes it (DuckDB's
507
+ - **CHECK constraints.** `CHECK (col IN ('a', 'b'))` and `CHECK (col = v)`,
508
+ over literals and joined by AND, state col's Enumerated Domain, as ENUM
509
+ does (NULL passes a CHECK, and is outside every domain). They are trusted
510
+ like keys: Knowledge where the database checks them, a Property
511
+ Declaration under `trust_unenforced_keys` in Snowflake, BigQuery,
512
+ Redshift, Trino, Hive and Databricks / Spark. Any other CHECK is ignored
513
+ with an `ignored-check-constraint` warning.
514
+ - **Text.** `VARCHAR` and `TEXT` are taken to compare by identity in
515
+ DuckDB, PostgreSQL and Trino, whose shipped default collation is binary
516
+ (Trino has no collations); a setting that changes it (DuckDB's
483
517
  `SET default_collation`) is out of scope. MySQL's default collations ignore case, and the warehouses are
484
- not yet certified, so their text is not. Text with any `COLLATE` is never
485
- taken to compare by identity.
518
+ not yet certified, so their text is not. sqlassert supports each dialect's
519
+ default collation only: a `COLLATE` is opaque and warns
520
+ `unsupported-construct`, and a column declared with one is untyped.
486
521
  - **Zoned timestamps.** A TIMESTAMP WITH TIME ZONE compares by identity where
487
522
  it holds an instant only (DuckDB, PostgreSQL, MySQL, BigQuery, Spark,
488
523
  Redshift). Trino and Snowflake keep the zone it was given, so equal instants
489
524
  cast to different text: there it does not, and comparing a `CAST` of one
490
525
  warns (`zoned-timestamp-cast`).
491
526
  - **NULL.** Arithmetic and CAST are taken never to return NULL for non-null
492
- operands only where they raise instead (DuckDB, PostgreSQL, Snowflake,
493
- BigQuery, Redshift, Trino); division likewise, except in DuckDB. Spark
494
- (outside ANSI mode) may return NULL even from a comparison. MySQL is modelled
527
+ operands only where they raise instead (DuckDB, PostgreSQL, BigQuery,
528
+ Redshift, Trino, and Spark and Databricks under ANSI mode, their default);
529
+ division likewise in PostgreSQL, Snowflake, BigQuery, Redshift, Trino and
530
+ Databricks. Spark and Hive may return NULL even from a comparison (a failed
531
+ implicit cast). Each engine is modelled at its latest release under its
532
+ default settings (ADR 0006). MySQL is modelled
495
533
  under its default strict `sql_mode`, in 8.4 and later: a comparison of
496
534
  non-null operands is non-null, arithmetic is not taken as checked. A CAST from JSON may be NULL everywhere (JSON `null`). `||` and
497
535
  `concat()` follow each dialect's NULL handling.
498
- - **MySQL `||`** is OR, or concatenation under `sql_mode` `PIPES_AS_CONCAT`,
499
- which also groups its operands differently, so it is an unknown function of
500
- its operands, with an `ambiguous-operator` warning: write `OR` or `CONCAT()`.
536
+ - **MySQL `||`** is OR, as under the default `sql_mode` (no `PIPES_AS_CONCAT`).
501
537
 
502
538
  ### Checking in CI
503
539
 
@@ -563,48 +599,81 @@ A column marker goes at the end of the Select Expression on that line; a join ma
563
599
 
564
600
  From Python, `suggest(sql)` returns the same suggestions, each with its `site`, `property`, `marker`, and `evidence`; `report.annotated()` returns the SQL with every marker pasted in. Only proved properties are suggested, each Unique Set in its strongest form (`NOT NULL UNIQUE` over `UNIQUE`) and minimal (no superset of another suggestion), and each join in its most specific proved form: `EXACTLY ONE`, then `ONE TO ONE`, then `MANY TO ONE` or `ONE TO MANY`. Unique Sets are searched exhaustively up to `max_size` columns (default 3); a wider one is still found when no smaller one exists. Properties the SQL already asserts or declares are not suggested again.
565
601
 
566
- #### Improvements
602
+ #### Rewrites
567
603
 
568
- Before any marker, `suggest` lists improvements to the SQL itself (level `high`; markers are `mid`). Each is a rewrite a proof shows leaves the result unchanged, row for row:
604
+ Before any marker, `suggest` lists rewrites to the SQL itself (type `rewrite`; markers are `marker`). Each is a rewrite a proof shows leaves the result unchanged, row for row, printed as the reason and a unified diff of the exact edits that make it. The edits are placed from the SQL's tokens and change only what the rewrite needs: the rest of the text, comments and markers included, stays as written. One that may change an output column's type or precision, or overflow where the original did not, is a `rewrite with caveat`, listed after the others: its message ends with a `Caveat:` naming the column and the risk (sqlassert has no result-type model per dialect, so precision and type differences are caveated, never refused). A plain `rewrite` never turns a query that runs into one that fails.
605
+
606
+ ```sql
607
+ create table users (id integer primary key, name varchar);
608
+ create table coupons (id integer primary key, code varchar);
609
+ create table orders (id integer primary key, user_id integer not null references users (id), coupon_id integer);
610
+ with big as (select * from orders where user_id > 100)
611
+ select o.id, u.name, u.id as user_id
612
+ from orders o
613
+ left join users u on u.id = o.user_id
614
+ left join coupons c on c.id = o.coupon_id
615
+ group by o.id, u.name, u.id;
616
+ ```
569
617
 
570
618
  ```bash
571
619
  $ sqlassert suggest orders.sql
572
- high line 4 CTE big Unused CTE CTE big is never referenced, so it never runs and its markers go unchecked: delete it
573
- high 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
574
- high 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
575
- high line 9 Root Select Redundant GROUP BY (o.id, u.name) determine u.id, NULL equal to NULL: drop u.id from GROUP BY and select any_value(u.id) AS user_id
576
- mid line 7 LEFT JOIN users AS u Exactly One Join /**ASSERT EXACTLY ONE**/
620
+ rewrite line 4 CTE big Unused CTE CTE big is never referenced, so it never runs and its markers go unchecked: delete it
621
+ --- orders.sql
622
+ +++ orders.sql (rewritten)
623
+ @@ -2,5 +2,4 @@
624
+ create table coupons (id integer primary key, code varchar);
625
+ create table orders (id integer primary key, user_id integer not null references users (id), coupon_id integer);
626
+ -with big as (select * from orders where user_id > 100)
627
+ select o.id, u.name, u.id as user_id
628
+ from orders o
629
+ 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
630
+ ...
631
+ rewrite line 9 Root Select GROUP BY of one row per group no two rows agree on ('o.id', 'u.name', 'u.id'), NULL equal to NULL, so every group is one row: drop GROUP BY and write each aggregate as its value over that row
632
+ --- orders.sql
633
+ +++ orders.sql (rewritten)
634
+ @@ -6,4 +6,3 @@
635
+ from orders o
636
+ left join users u on u.id = o.user_id
637
+ -left join coupons c on c.id = o.coupon_id
638
+ -group by o.id, u.name, u.id;
639
+ +left join coupons c on c.id = o.coupon_id;
640
+ marker line 7 LEFT JOIN users AS u Exactly One Join /**ASSERT EXACTLY ONE**/
577
641
  ...
578
642
  ```
579
643
 
580
- | Improvement | When |
644
+ Each diff is of that rewrite alone, against the original SQL.
645
+
646
+ | Rewrite | When |
581
647
  |---|---|
582
648
  | `INNER JOIN` | A LEFT (or RIGHT) JOIN that never keeps a padded row: it matches exactly one row, or a later inner join's ON, a `WHERE EXISTS`/`IN` subquery, or the WHERE clause of the same Select rejects NULL in a column it pads, directly or through a later LEFT JOIN whose ON rejects that column (so it pads the same rows). |
583
649
  | Redundant Join | No column of the joined relation is used outside its own ON, and the join keeps every left row once: a LEFT JOIN with at most one match, or an Exactly One inner JOIN. |
584
- | Filter-Only Join | The same for an inner JOIN with at most one match: it only filters, so it can be a `WHERE EXISTS`. Not suggested when a RIGHT or FULL JOIN follows it. |
650
+ | Filter-Only Join | The same for an inner JOIN with at most one match: it only filters, so it moves into the WHERE as `EXISTS (SELECT 1 FROM <relation> WHERE <its ON>)`. Not suggested when a RIGHT or FULL JOIN follows it. |
585
651
  | Redundant DISTINCT | No two rows agree on the selected columns, NULL equal to NULL. |
586
652
  | Redundant ORDER BY key | The ORDER BY keys before it determine it, NULL equal to NULL: it never breaks a tie. Silent when a key is an expression or a name sqlassert cannot map to one column. |
587
653
  | Redundant GROUP BY | The remaining grouping columns determine this one, NULL equal to NULL. One grouping column always stays. |
654
+ | GROUP BY of one row per group | No two input rows agree on the grouping columns, NULL equal to NULL: every group is one row, so `GROUP BY` goes and each aggregate is its value over that row (`count(*)` is 1, `count(x)` a `CASE`, `sum`, `avg`, `min`, `max`, `any_value`, `bool_and`, `bool_or` of x are x), in the select list and in `HAVING`, whose condition then moves into `WHERE` (`HAVING count(*) > 1` becomes `WHERE 1 > 1`). A rewrite with caveat when a type or precision changes: `sum(x)` of an INTEGER is a HUGEINT in DuckDB, `x` an INTEGER; `sum(x) + 1` may overflow as `x + 1`; `avg(x)` of a BIGINT, HUGEINT, UBIGINT or DECIMAL is `x`, its exact value, where avg's DOUBLE may round it. None where the value may differ otherwise (`sum` of a BOOLEAN, `avg` of an integer inside an expression, which may divide as an integer) or the argument's type is unknown, nor beside a call SQLGlot does not know (DuckDB's `mean` or `arbitrary`), which may be an aggregate the analysis does not model. Every spelling of a call it models is rewritten: with `ALL` or `DISTINCT`, IGNORE or RESPECT NULLS, BigQuery's `HAVING MAX`, or as an ODBC `{fn ...}` escape. |
588
655
  | Redundant EXISTS | A `WHERE EXISTS`, `IN` subquery or SEMI JOIN every row passes: each row matches exactly one row of it (a non-null Foreign Key onto a key, and an ON of column equalities only). |
589
656
  | Unused CTE | Nothing in its WITH reaches it, directly or through another CTE. Its markers are never checked either. |
590
657
 
591
- `report.improvements` holds them, each with its `site`, `rewrite`, `message`, and `evidence`; `--explain` prints the proofs. Padding is only followed within the join's own Select Expression: past it, a LIMIT, window, or aggregate may see the padded rows before a filter removes them.
658
+ `report.rewrites` holds them, each with its `site`, `kind`, `message`, `edits` (each an `Edit(start, end, replacement)` on the original SQL's offsets), `evidence`, and `suggest_type` (`SuggestType.REWRITE` or `SuggestType.REWRITE_WITH_CAVEAT`); `rewrite.rewritten(report.sql)` is the rewritten SQL and `rewrite.diff(report.sql)` its diff. `--explain` prints the proofs. Padding is only followed within the join's own Select Expression: past it, a LIMIT, window, or aggregate may see the padded rows before a filter removes them.
592
659
 
593
- Low-level smells come last: places whose result the SQL leaves unspecified. `report.smells` holds them, each with its `site`, `concern`, `message`, and the failed proof as `evidence`.
660
+ Hazards come last: places whose result the SQL leaves unspecified. `report.hazards` holds them, each with its `site`, `concern`, `message`, and the failed proof as `evidence`.
594
661
 
595
- | Smell | When |
662
+ | Hazard | When |
596
663
  |---|---|
597
664
  | Arbitrary LIMIT | A `LIMIT` or `OFFSET` whose `ORDER BY` (if any) does not determine every selected column, NULL equal to NULL: rows tied on the sort keys may come in any order, so which rows are kept can change between runs. Silent when an `ORDER BY` key is an expression or a name sqlassert cannot map to one column. |
598
665
  | Scalar subquery | A scalar subquery not proved to return at most one row, a runtime error when it returns more: uncorrelated, its body is not proved to have at most one row; correlated, the columns its WHERE binds to the outer row are not proved a Unique Set. |
599
666
  | Implicit Cast | A join equality between a text column and a column of another declared type: the text is cast, so different strings may match one value (`'01'` and `'1'` both equal 1). No cardinality is proved across it either: cast explicitly, and the proof stays `UNKNOWN`, which is correct. |
667
+ | Float equality | An equality (`=`, `<>`, `IS [NOT] DISTINCT FROM`, an `IN` list or subquery) with an operand of a known floating type (REAL, FLOAT, DOUBLE), against another float, an integer, a decimal or a literal: floats round, so `x = 0.1` misses a DOUBLE computed as `0.1 + 0.2 - 0.2`, and `a.id = d.x` of a BIGINT and a DOUBLE matches two ids above 2^53. In a join's ON, a WHERE or HAVING, and an `IN` or `EXISTS` correlation, in every dialect. Silent for an ordering (`<`, `>`) and an operand whose type is unknown. Compare within a tolerance or use an exact type. |
600
668
  | Fan Trap | An aggregate over a join that is not proved to repeat rows of only one input, when its argument (or, for `count(*)`, either input) comes from rows the join may repeat: `sum(p.amount)` over `orders JOIN payments USING (customer_id)`. |
601
669
  | Chasm Trap | An aggregate over a one-to-many join whose argument is on the side with one row per key: `sum(c.credit)` over `customers JOIN orders`. Every aggregate counts, `min` and `max` included. Silent when the repeated input has no known Unique Set, or the argument reads both inputs. |
670
+ | Many-to-many join | A join with no join marker that is not proved to repeat rows of only one input, both inputs having a known Unique Set: `orders JOIN payments USING (customer_id)` repeats each order once per payment and each payment once per order. A many-to-many join is rarely meant. Silent for an explicit `CROSS JOIN`, a semi or anti join, a join in the FROM of a Select whose `DISTINCT` or `GROUP BY` merges the repeats (an aggregate's trap says what they do to it), and a join whose ON equates every column of a known key of one input, when only an unknown column type or an expression keeps the proof from binding it. Write the join marker you expect (`/**ASSERT MANY TO ONE**/`, ...) and `check` proves it or says why not. |
602
671
 
603
672
  `NATURAL JOIN` is unsupported: its presence anywhere in the program produces an `unsupported-natural-join` diagnostic, and `suggest` returns no suggestions. Write explicit `ON` or `USING` conditions instead.
604
673
 
605
674
  ### dbt
606
675
 
607
- The `sqlassert-dbt` plugin, a separate package in this repository (`integrations/dbt/`), checks a compiled dbt project from its `target/manifest.json` (run `dbt compile` or `dbt build` first). It reads only the manifest, so dbt itself is not needed where it runs, and only the latest manifest schema (v12, written by dbt 1.8 through 1.12): compile with a current dbt.
676
+ The `sqlassert-dbt` plugin, a separate package in this repository (`integrations/dbt/`), checks a compiled dbt project from its `target/manifest.json` (run `dbt compile` or `dbt build` first). It reads only the manifest, so dbt itself is not needed where it runs, and only the latest manifest schema (v12, written by dbt 1.8 through 1.12): compile with a current dbt. `target/catalog.json` (written by `dbt docs generate`), read when present, adds the columns and types of sources, seeds and other tables the manifest leaves unknown, except where the project shows the catalog stale; `--catalog PATH` names another.
608
677
 
609
678
  ```bash
610
679
  $ pip install sqlassert-dbt # depends on sqlassert; sqlassert does not depend on it
@@ -633,6 +702,14 @@ $ sqlassert-dbt build . -- --target prod # or: sqlassert-dbt test
633
702
 
634
703
  It runs `dbt compile`, prints the check, then runs `dbt build` (or `dbt test`) with every proved test passed as `--exclude`. dbt runs the upstream tests in that same invocation, so they are trusted, unless the arguments after `--` select nodes (`--select`, `--exclude`, `--selector`, ...), which may leave one out. The exit code is dbt's when dbt fails, else that of the check.
635
704
 
705
+ To see what sqlassert can prove about the models you are editing, as `sqlassert suggest` would on plain SQL:
706
+
707
+ ```bash
708
+ $ sqlassert-dbt suggest models/customers.sql models/stg_orders.sql --explain -- --target dev
709
+ ```
710
+
711
+ It compiles those models and what they read, then lists the rewrites, markers and hazards for each model at its file's lines, with what the model reads declared as `check` declares it. In an incremental model, a rewrite or marker is listed only when both `is_incremental()` branches prove it.
712
+
636
713
  ## Details
637
714
 
638
715
  ### Join Cardinality Syntax
@@ -723,3 +800,8 @@ More compile-time SQL checks can be added under the same model: explicit syntax,
723
800
  ## Roadmap
724
801
 
725
802
  Open work is tracked as one file per issue in [`docs/issues/`](https://github.com/polvoazul/sqlassert/blob/main/docs/issues/README.md).
803
+
804
+ ## Citation
805
+
806
+ If you use sqlassert in published research, please cite the version you used.
807
+ See [CITATION.cff](CITATION.cff) for citation details.
@@ -0,0 +1,46 @@
1
+ sqlassert_cli.py,sha256=7VCs-E3JvpEo-fvC-wFZleIwMOtQik5WE4NuAuOlw_c,6624
2
+ sqlassert/__init__.py,sha256=djiGuSufeXXL-PhI5VFfeSO7eo-tgknDIeOiC8JIklM,1099
3
+ sqlassert/__main__.py,sha256=Nff1ukQ2Rc6dievyqikylZyQ6lMze7CDjkOwmTaW3H0,157
4
+ sqlassert/check.py,sha256=YVrnJVL7UPPIFrVrO8WxWI2hQnl4huwsWV5PIaZljhk,17591
5
+ sqlassert/diagnostics.py,sha256=NdqKtvxhIGS2IZ0FrbMPO8k6B1xDOfEiPE0zUeroGxg,2905
6
+ sqlassert/dialects.py,sha256=SNfo-zwd4iKXHYJvzbK4cq9-tZvv1jW9-Arhinik2GY,11748
7
+ sqlassert/edits.py,sha256=gBfECLK6WrwlVXIHIOwH2flxkzLO1JquUXAQPzI5XEE,10568
8
+ sqlassert/hazards.py,sha256=Z7Hb9Bh6m6p7pRy6vyLI0uBl363hFtY2ObnbcR5Ijvo,29658
9
+ sqlassert/main.py,sha256=5rJGF0LU-E8z-HTkdrMVd7joQgZ0AkwnDgqHy4OdGl0,2312
10
+ sqlassert/properties.py,sha256=0PfG6bJbElPrHAyaC7TcQueacmZ5g6zVtjSrCgLbn2k,3460
11
+ sqlassert/provenance.py,sha256=MmGR_b6tdjjgfeN40SG3JjAmVJuPFNnkbSfV4ZFdlMU,2158
12
+ sqlassert/python_engine.py,sha256=9sSwOAokHJzRazjk4JGUbHLulIvsVZfWidorsf7aLEA,15414
13
+ sqlassert/reporting.py,sha256=69VL1vhWl_ZRXS4ug7Z6ZDFJV4M4VAckjcGfumKFo_s,3798
14
+ sqlassert/rewrites.py,sha256=uhU0VgCPzhllrTkgj4nHKDozQ4-lahCpS_xx4otFk-M,81835
15
+ sqlassert/sql_parse.py,sha256=qwDnMKW0Eh7xY_aCUei5A_1_dIDw8F1Sq6uE7odc5Kg,52853
16
+ sqlassert/suggest.py,sha256=xHlfInnuenzRUlPxjU3562tP3lNa4q75HmT9T_yLXYo,19892
17
+ sqlassert/discovery/__init__.py,sha256=pa9tv0G_YRJEFYO-aPPOQtvhc3YVg4_WZ1bYQqraoBU,854
18
+ sqlassert/discovery/bigquery.py,sha256=WgWnLd5Ik8vBLDwlH8ACcV11OYwJLPAQDaR8WWN2Kl0,3373
19
+ sqlassert/discovery/databricks.py,sha256=Ir4yhtvwoLzQXfpPehxFXPJOUReIb22rualaWHv1s6g,750
20
+ sqlassert/discovery/duckdb.py,sha256=8SPcunkdLftHtSF-VcjXrSQTZy64gjbpOHI17x-HA5k,7783
21
+ sqlassert/discovery/fetcher.py,sha256=HmO8fPOQAAnacSv2LMzTNUWZ9z7mWDGSDTg-o9E8zYc,20524
22
+ sqlassert/discovery/information_schema.py,sha256=5XNmcYpGWejJnEfUzbBCJ06Y70uqSb7DVV37FLpf0lo,16653
23
+ sqlassert/discovery/mysql.py,sha256=_oQynTv2BFWJ93H6aT1gY-lUaofLagUUFgD7unt3H0c,3390
24
+ sqlassert/discovery/postgres.py,sha256=wKNEcYrVvPGMxYtNUCa5k_XIVzgXTFfNqBrNCXSAiyw,6623
25
+ sqlassert/discovery/redshift.py,sha256=_QWfwBwAf9lhMjbDbqfjLbkRZ2LLpvC5ZGqH_O3RxtE,1669
26
+ sqlassert/discovery/snowflake.py,sha256=kJzwVk_trVRIC_H5_LmBjVXup-hMJBnYg1GWRf5utBM,3115
27
+ sqlassert/discovery/trino.py,sha256=xRnyk_jPQGann1sXYCSJw2JxfMWwF7uiuvE0wzyLKMM,1664
28
+ sqlassert/ir/__init__.py,sha256=0dFG-19LH6iB3PEe3vEUcjgQgqrFAi2FDC_BbTViHTs,1618
29
+ sqlassert/ir/convert.py,sha256=1F_CvHJWKHOE-OzEHkv8RVZjm2-mrh3kEhyOVJ5CKoY,193658
30
+ sqlassert/ir/model.py,sha256=2lJ1qMUtLTYiBrjfXakRkEYfnwpjmHUGq1-IGH_BM6s,30976
31
+ sqlassert/rules/STYLEGUIDE.md,sha256=8Oqy6vPdJ5LZ5zjKCfd5oVTWjwFHhb6NMrmHpAxqZ0c,1435
32
+ sqlassert/rules/__init__.py,sha256=VwDKt2zRCexIWxHwrZRBpvW0T6Ziesg-S7edcrQRiAo,526
33
+ sqlassert/rules/column_set.py,sha256=CFUz1iVC88gsg2iRcqe7h6hOR8sLfrvk80C1S5JGmuM,772
34
+ sqlassert/rules/domain.py,sha256=sabc3GOU72VgVLpLU1I1ZwO1QdVIiyofTMFgRslrLcQ,24652
35
+ sqlassert/rules/equality.py,sha256=EuFHZv9_3qf8N_fmQgV8xK7tnwfJ1aq4Nj1C0q3-gXk,22562
36
+ sqlassert/rules/exactly_one.py,sha256=X8jORy9Qy08c-uPCg2POOVhV1u_6aZaqofpq8I3Nnac,5814
37
+ sqlassert/rules/foreign_key.py,sha256=OMBbsegcvOO0Aj0ErlKi0yHMGPzxtuzUXQKWBVOQgGo,16943
38
+ sqlassert/rules/join_cardinality.py,sha256=sQBCStlbBROZrWhpBRxW41RQ_vJLbvNeURp7lLYohvc,5863
39
+ sqlassert/rules/nullability.py,sha256=f7Nl0ch7v4D5MsPKiPwME0M4h-WsfUbCw_LSxWJd23A,32278
40
+ sqlassert/rules/uniqueness.py,sha256=kT17SSAvptY5rBWLavDZNl8kts_2SGwBJWx8i5xudgs,48154
41
+ sqlassert-0.3.3.dist-info/licenses/LICENSE,sha256=KCR0_j-gr5ufUNxamIKNzeyyiI6g-S69oecRjZ07l_A,1068
42
+ sqlassert-0.3.3.dist-info/METADATA,sha256=1sUeFFoobB1esfilFDFMe0SROeExPXSKbXHbWwYlWw4,54509
43
+ sqlassert-0.3.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
44
+ sqlassert-0.3.3.dist-info/entry_points.txt,sha256=IsOK1YYQWT9mEMV_fK0HC4oCgUQcGkI66qe4ba2LESM,49
45
+ sqlassert-0.3.3.dist-info/top_level.txt,sha256=6ncb3DFuCf-65HNbRHF7l3x2sDg9jjxoXQpI_P_oR5g,24
46
+ sqlassert-0.3.3.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sqlassert = sqlassert_cli:main
@@ -0,0 +1,2 @@
1
+ sqlassert
2
+ sqlassert_cli