Skip to content

Commit 00de4e8

Browse files
Update README and example outputs for clarity and consistency
1 parent 0f8ad2e commit 00de4e8

6 files changed

Lines changed: 108 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ sqlcompare analyze-diff <diff_id> --missing-current
6262

6363
## Example outputs
6464

65-
See `examples/README.md` for datasets, commands, and captured outputs.
65+
See `examples/` for datasets, commands, and captured outputs.
6666

67-
- Row comparison output: `examples/row_compare/output.txt`
68-
- Statistical comparison output: `examples/stats_compare/output.txt`
67+
- Row comparison output: `examples/row_compare.md`
68+
- Statistical comparison output: `examples/stats_compare.md`
6969

7070
---
7171

examples/row_compare.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Row Compare
2+
3+
Compare rows using a dataset YAML with file inputs
4+
5+
```text
6+
Prepared dataset tables: examples.dataset_dataset_1f232b87_previous, examples.dataset_dataset_1f232b87_new
7+
✅ Ensured schema 'examples' exists
8+
Joining tables: examples.dataset_dataset_1f232b87_previous and examples.dataset_dataset_1f232b87_new
9+
Rows only in current dataset: 1
10+
+----+-------+--------+--------+
11+
| id | name | amount | status |
12+
+----+-------+--------+--------+
13+
| 4 | delta | 40 | open |
14+
+----+-------+--------+--------+
15+
Rows only in previous dataset: 1
16+
+----+-------+--------+--------+
17+
| id | name | amount | status |
18+
+----+-------+--------+--------+
19+
| 2 | bravo | 20 | open |
20+
+----+-------+--------+--------+
21+
🚨 Differences in values for common rows: 2 rows in total
22+
23+
📊 Difference statistics by column:
24+
+-------------+------------+
25+
| COLUMN_NAME | diff_count |
26+
+-------------+------------+
27+
| name | 1 |
28+
| amount | 1 |
29+
+-------------+------------+
30+
31+
✅ Columns with no differences: status
32+
33+
📋 Sample differences (first 10 rows):
34+
+----+--------+--------+---------+
35+
| id | COLUMN | BEFORE | CURRENT |
36+
+----+--------+--------+---------+
37+
| 1 | name | alpha | alfa |
38+
| 1 | amount | 10 | 11 |
39+
+----+--------+--------+---------+
40+
🔎 To review the diff, run: sqlcompare analyze-diff compare_examples_dataset_dataset_1f232b87_previous_examples_dataset_dataset_1f232b87_new_20260103_234457_9180044d
41+
💡 Tips: --stats for per-column counts, --missing-current/--missing-previous for row-only, --column <name> to filter, --list-columns to inspect available fields.
42+
```

examples/row_compare_missing.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Row Compare Missing
2+
3+
Show rows only in current/previous after a dataset comparison
4+
5+
```text
6+
📂 Loaded diff data: 1 total differences
7+
📊 Showing 1 of 1 differences:
8+
+-------------+---------------+-----------------+-----------------+--------+----------+------------+------------+
9+
| id_previous | name_previous | amount_previous | status_previous | id_new | name_new | amount_new | status_new |
10+
+-------------+---------------+-----------------+-----------------+--------+----------+------------+------------+
11+
| | | | | 4 | delta | 40 | open |
12+
+-------------+---------------+-----------------+-----------------+--------+----------+------------+------------+
13+
```

examples/stats_compare.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Stats Compare
2+
3+
Compare statistics between two CSV files
4+
5+
```text
6+
📊 Table statistics comparison:
7+
+-------------+-----------+----------+------------+-----------+---------------+--------------+-----------+------------+---------------+
8+
| COLUMN_NAME | PREV_ROWS | NEW_ROWS | PREV_NULLS | NEW_NULLS | PREV_DISTINCT | NEW_DISTINCT | ROWS_DIFF | NULLS_DIFF | DISTINCT_DIFF |
9+
+-------------+-----------+----------+------------+-----------+---------------+--------------+-----------+------------+---------------+
10+
| id | 5 | 6 | 0 | 0 | 5 | 6 | 1 | 0 | 1 |
11+
| segment | 5 | 6 | 0 | 0 | 3 | 3 | 1 | 0 | 0 |
12+
| amount | 5 | 6 | 0 | 0 | 4 | 5 | 1 | 0 | 1 |
13+
| notes | 5 | 6 | 2 | 1 | 1 | 1 | 1 | -1 | 0 |
14+
+-------------+-----------+----------+------------+-----------+---------------+--------------+-----------+------------+---------------+
15+
```

examples/stats_compare_tables.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Stats Compare Tables
2+
3+
Compare statistics between tables loaded into DuckDB
4+
5+
```text
6+
📊 Table statistics comparison:
7+
+-------------+-----------+----------+------------+-----------+---------------+--------------+-----------+------------+---------------+
8+
| COLUMN_NAME | PREV_ROWS | NEW_ROWS | PREV_NULLS | NEW_NULLS | PREV_DISTINCT | NEW_DISTINCT | ROWS_DIFF | NULLS_DIFF | DISTINCT_DIFF |
9+
+-------------+-----------+----------+------------+-----------+---------------+--------------+-----------+------------+---------------+
10+
| id | 5 | 6 | 0 | 0 | 5 | 6 | 1 | 0 | 1 |
11+
| segment | 5 | 6 | 0 | 0 | 3 | 3 | 1 | 0 | 0 |
12+
| amount | 5 | 6 | 0 | 0 | 4 | 5 | 1 | 0 | 1 |
13+
| notes | 5 | 6 | 2 | 1 | 1 | 1 | 1 | -1 | 0 |
14+
+-------------+-----------+----------+------------+-----------+---------------+--------------+-----------+------------+---------------+
15+
```

scripts/generate_examples/run.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,33 @@ def main() -> int:
4949
for name, config in examples.items():
5050
if not isinstance(config, dict):
5151
raise ValueError(f"Example '{name}' must be a mapping.")
52+
description = config.get("description")
53+
if not description or not isinstance(description, str):
54+
raise ValueError(f"Example '{name}' is missing a description string.")
55+
title = config.get("title")
56+
if not title or not isinstance(title, str):
57+
title = name.replace("_", " ").title()
5258
command = config.get("command")
5359
if not command or not isinstance(command, str):
5460
raise ValueError(f"Example '{name}' is missing a command string.")
5561

5662
print(f"Generating example '{name}'...")
5763
output = _run_command(command, root, env)
58-
output_path = root / "examples" / name / "output.txt"
64+
markdown_output = "\n".join(
65+
[
66+
f"# {title}",
67+
"",
68+
description,
69+
"",
70+
"```text",
71+
output.rstrip("\n"),
72+
"```",
73+
"",
74+
]
75+
)
76+
output_path = root / "examples" / f"{name}.md"
5977
output_path.parent.mkdir(parents=True, exist_ok=True)
60-
output_path.write_text(output, encoding="utf-8")
78+
output_path.write_text(markdown_output, encoding="utf-8")
6179

6280
return 0
6381

0 commit comments

Comments
 (0)