Skip to content

Commit 454b11e

Browse files
author
chunyu
committed
fix bugs and revise default parameters
1 parent 0472de0 commit 454b11e

2 files changed

Lines changed: 49 additions & 31 deletions

File tree

README.md

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,54 +27,72 @@ print(result.success, result.generation.rows_generated)
2727
### Disprove Query Equivalence
2828

2929
```python
30-
from parseval import disprove, Semantics
30+
from parseval import disprove
3131

3232
result = disprove(
3333
sql1="SELECT name FROM users WHERE age > 25",
3434
sql2="SELECT name FROM users WHERE age >= 26",
3535
schema="CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)",
3636
connection_string="sqlite:////tmp/test.db",
3737
dialect="sqlite",
38-
semantics=Semantics.BAG, # or Semantics.SET
38+
semantics="bag", # or Semantics.SET
3939
)
4040
print(result.verdict) # Verdict.EQ or Verdict.NEQ
4141
```
4242

43-
### Supported Dialects
43+
### Coverage Thresholds
4444

45-
- `sqlite` — full support
46-
- `mysql` — supported via DBManager
47-
- `postgres` — supported via DBManager
45+
Control how many rows are generated per branch type. Set a threshold to `0` to skip that branch type entirely. Higher values generate more rows but improve coverage.
46+
47+
```python
48+
result = instantiate_db(
49+
sql="SELECT name FROM users WHERE age > 25",
50+
schema="CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)",
51+
connection_string="sqlite:////tmp/test.db",
52+
dialect="sqlite",
53+
atom_null=2, # Generate 2 rows where WHERE evaluates to NULL
54+
atom_false=1, # Generate 1 row where WHERE is FALSE
55+
project_null=1, # Generate 1 row where SELECT output is NULL
56+
distinct_duplicate=1, # Generate 1 duplicate row for DISTINCT elimination
57+
distinct_unique=1, # Generate 1 unique row for DISTINCT
58+
)
59+
```
60+
61+
| Parameter | Description | Default |
62+
|-----------|-------------|---------|
63+
| `atom_null` | Rows where a WHERE/ON predicate evaluates to NULL | 1 |
64+
| `atom_false` | Rows where a WHERE/ON predicate is FALSE | 1 |
65+
| `atom_dup` | Rows that trigger duplicate detection | 1 |
66+
| `project_null` | Rows where a projected column is NULL | 1 |
67+
| `distinct_duplicate` | Duplicate rows eliminated by DISTINCT | 1 |
68+
| `distinct_unique` | Unique rows retained by DISTINCT | 1 |
69+
| `max_iterations` | Max iterations for the symbolic engine | 10 |
70+
71+
### Connection Strings
72+
73+
```python
74+
# SQLite
75+
connection_string="sqlite:////tmp/test.db"
76+
77+
# MySQL
78+
connection_string="mysql+pymysql://user:password@localhost:3306/mydb"
79+
80+
# PostgreSQL
81+
connection_string="postgresql://user:password@localhost:5432/mydb"
82+
```
4883

4984
## File Structure
5085

5186
```
5287
src/parseval/
5388
├── main.py # Public API: instantiate_db, disprove
54-
├── symbolic/
55-
│ ├── engine.py # SymbolicEngine — orchestrates generation
56-
│ ├── speculate.py # Speculative data generation (Propagator + Resolver)
57-
│ ├── evaluator.py # Branch coverage evaluation
58-
│ ├── uexpr.py # UExprToConstraint — Z3-based constraint solver
59-
│ ├── constraints.py # Coverage gap → solver constraint translation
60-
│ └── types.py # BranchType, CoverageTarget, BranchTree
61-
├── solver/
62-
│ ├── unified.py # Tiered solver (Trivial → Heuristic → CSP → SMT)
63-
│ ├── smt.py # Z3 SMT solver with SQL-to-Z3 translation
64-
│ ├── lowering.py # Predicate lowering (SQL → column constraints)
65-
│ └── value_space.py # CSP domain narrowing
66-
├── plan/
67-
│ ├── planner.py # Query plan builder (Scan, Join, Filter, etc.)
68-
│ ├── rex.py # Concrete expression evaluation + Symbol types
69-
│ └── context.py # Row/Environment for plan evaluation
70-
├── instance/
71-
│ ├── core.py # Instance — in-memory row management
72-
│ ├── io.py # Persistence (to_db)
73-
│ └── loader.py # SQLAlchemy-based DB writer
74-
├── domain/ # Type-aware value generation
75-
├── db_manager.py # Multi-backend connection management
76-
├── logger.py # Configurable logging
77-
└── states.py # Result types (Verdict, DisproveResult, etc.)
89+
├── disprover.py # Query equivalence disproval
90+
├── states.py # Result types (Verdict, DisproveResult, etc.)
91+
├── symbolic/ # Coverage-driven data generation engine
92+
├── solver/ # Constraint satisfaction (CSP + SMT/Z3)
93+
├── plan/ # Query plan analysis
94+
├── instance/ # In-memory row management and persistence
95+
└── domain/ # Type-aware value generation
7896
```
7997

8098
## Running Experiments

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "parseval"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
description = "Plan-aware Test Database Generation for SQL Equivalence Evaluation"
55
authors = [
66
{ name = "Your Name", email = "you@example.com" }

0 commit comments

Comments
 (0)