streaming-sql-engine 0.1.31__tar.gz → 0.2.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 (36) hide show
  1. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/MANIFEST.in +1 -0
  2. streaming_sql_engine-0.1.31/README.md → streaming_sql_engine-0.2.1/PKG-INFO +151 -1
  3. streaming_sql_engine-0.1.31/PKG-INFO → streaming_sql_engine-0.2.1/README.md +1691 -1640
  4. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/__init__.py +1 -1
  5. streaming_sql_engine-0.2.1/app/__init__.py +8 -0
  6. streaming_sql_engine-0.2.1/app/__main__.py +46 -0
  7. streaming_sql_engine-0.2.1/app/demo.py +106 -0
  8. streaming_sql_engine-0.2.1/app/jobs.py +165 -0
  9. streaming_sql_engine-0.2.1/app/server.py +288 -0
  10. streaming_sql_engine-0.2.1/app/sources.py +320 -0
  11. streaming_sql_engine-0.2.1/app/static/app.css +467 -0
  12. streaming_sql_engine-0.2.1/app/static/app.js +1283 -0
  13. streaming_sql_engine-0.2.1/app/static/index.html +202 -0
  14. streaming_sql_engine-0.2.1/app/worker.py +819 -0
  15. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/core/evaluator.py +21 -5
  16. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/core/executor.py +12 -3
  17. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/core/optimizer.py +470 -470
  18. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/core/planner.py +174 -174
  19. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/engine.py +10 -5
  20. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/operators/base.py +520 -586
  21. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/operators/mmap.py +262 -332
  22. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/operators/polars.py +732 -732
  23. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/pyproject.toml +80 -67
  24. streaming_sql_engine-0.2.1/run_app.py +17 -0
  25. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/storage/__init__.py +4 -2
  26. streaming_sql_engine-0.2.1/storage/file_index.py +405 -0
  27. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/storage/mmap_index.py +391 -391
  28. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/streaming_sql_engine.egg-info/SOURCES.txt +24 -0
  29. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/core/__init__.py +0 -0
  30. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/core/parser.py +0 -0
  31. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/operators/__init__.py +0 -0
  32. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/polars_utils/__init__.py +0 -0
  33. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/polars_utils/operators.py +0 -0
  34. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/polars_utils/translator.py +0 -0
  35. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/requirements.txt +0 -0
  36. {streaming_sql_engine-0.1.31 → streaming_sql_engine-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,7 @@
1
1
  include README.md
2
2
  include requirements.txt
3
3
  recursive-include streaming_sql_engine *.py
4
+ recursive-include app/static *
4
5
  recursive-exclude test *
5
6
  recursive-exclude test_data *
6
7
  recursive-exclude build *
@@ -1,3 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: streaming-sql-engine
3
+ Version: 0.2.1
4
+ Summary: Streaming SQL Engine: Lightweight Cross Data Source Integration for Resource Constraint Environments
5
+ Home-page: https://github.com/Ierofantis/streaming_sql_engine/
6
+ Author: Ierofantis
7
+ Author-email: Ierofantis <teopanta1986@gmail.com>
8
+ Project-URL: Homepage, https://github.com/Ierofantis/streaming_sql_engine/
9
+ Project-URL: Repository, https://github.com/Ierofantis/streaming_sql_engine/
10
+ Project-URL: Issues, https://github.com/Ierofantis/streaming_sql_engine/issues
11
+ Project-URL: Documentation, https://github.com/Ierofantis/streaming_sql_engine/blob/master/README.md
12
+ Project-URL: Scientific-Paper, https://github.com/Ierofantis/streaming_sql_engine/blob/master/Streaming_SQL_Engine_Paper.pdf
13
+ Keywords: sql,streaming,join,database,query,engine,etl,data-integration
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Topic :: Database
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ Requires-Dist: sqlglot>=23.0.0
28
+ Requires-Dist: polars>=0.19.0
29
+ Provides-Extra: db
30
+ Requires-Dist: psycopg2-binary>=2.9.0; extra == "db"
31
+ Requires-Dist: pymysql>=1.0.0; extra == "db"
32
+ Requires-Dist: DBUtils>=3.0.0; extra == "db"
33
+ Requires-Dist: pymongo>=4.0.0; extra == "db"
34
+ Provides-Extra: app
35
+ Requires-Dist: fastapi>=0.100.0; extra == "app"
36
+ Requires-Dist: uvicorn>=0.23.0; extra == "app"
37
+ Requires-Dist: psutil>=5.9.0; extra == "app"
38
+ Requires-Dist: openpyxl>=3.1.0; extra == "app"
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
41
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
42
+ Requires-Dist: black>=23.0.0; extra == "dev"
43
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
44
+ Provides-Extra: all
45
+ Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
46
+ Requires-Dist: pymysql>=1.0.0; extra == "all"
47
+ Requires-Dist: DBUtils>=3.0.0; extra == "all"
48
+ Requires-Dist: pymongo>=4.0.0; extra == "all"
49
+ Dynamic: author
50
+ Dynamic: home-page
51
+ Dynamic: requires-python
52
+
1
53
  # Streaming SQL Engine: Join Data from Anywhere
2
54
 
3
55
  Join data from MySQL, PostgreSQL, MongoDB, REST APIs, CSV files, and more — all in one SQL query, without infrastructure or data import.
@@ -67,6 +119,104 @@ for row in engine.query(query):
67
119
 
68
120
  ---
69
121
 
122
+ ## File Compare app
123
+
124
+ A local web app on top of the engine: compare two or more large CSV, TSV, JSONL or Excel files by a key and watch the join run live. Nothing is uploaded; it runs on your machine and opens in your browser.
125
+
126
+ ```bash
127
+ pip install "streaming-sql-engine[app]"
128
+ sse-compare # or: python -m streaming_sql_engine.app
129
+ ```
130
+
131
+ From a source checkout: `python run_app.py`.
132
+
133
+ ![File Compare after a run: totals, join flow, throughput and memory charts, result rows, and the session's runs with Python, Rust and DuckDB side by side](https://raw.githubusercontent.com/Ierofantis/streaming_sql_engine/master/docs/app-runs.png)
134
+
135
+ While a comparison runs, the counters, charts and result rows update live:
136
+
137
+ ![File Compare during a run](https://raw.githubusercontent.com/Ierofantis/streaming_sql_engine/master/docs/app-running.png)
138
+
139
+ 1. Pick file A and file B (or generate synthetic demo files). "Add another file" adds file C, D and so on, up to twelve.
140
+ 2. Confirm the key columns; the app suggests them from column names and sample values.
141
+ 3. Choose what to show: rows in all files, rows only in one of them, or matched rows whose values differ.
142
+ 4. Press Run. Rows, throughput and memory update live, the generated SQL is shown, and the result downloads as CSV.
143
+
144
+ ### More than two files
145
+
146
+ Every other file is matched against file A on its own key column.
147
+
148
+ - **Rows in all files:** the key is present in every file. The result has the columns of all of them.
149
+ - **Rows only in C** (or any other file): rows of that file whose key is in none of the others.
150
+ - **Matched rows whose values differ:** rows present in every file where a column of A differs from the column you paired it with in another file. Each pair names its file.
151
+
152
+ The comparison runs as one join per extra file: A with B, the result with C, and so on. The page shows which step is running. Every join strategy works this way except the DuckDB comparison, which is set up for two files.
153
+
154
+ ![Four files compared: values that differ across a catalog, a supplier feed, a warehouse file and a marketplace file](https://raw.githubusercontent.com/Ierofantis/streaming_sql_engine/master/docs/app-four-files.png)
155
+
156
+ ### Join strategies
157
+
158
+ The "File index in Rust" strategy (files in any order) and the "Merge in Rust" strategies (files already sorted by the key) use an optional native extension that runs on all cores. It reads CSV and TSV. Build it once from a checkout (needs the Rust toolchain):
159
+
160
+ ```bash
161
+ pip install maturin
162
+ cd native && maturin develop --release
163
+ ```
164
+
165
+ How the Rust code works, step by step: [docs/rust-kernels.md](docs/rust-kernels.md).
166
+
167
+ Each run happens in its own process, so the memory figure is the cost of that run alone. Run the same comparison with the "In-memory hash" strategy to see the difference against the default file index join.
168
+
169
+ "DuckDB (for comparison)" runs the same comparison in DuckDB if it is installed (`pip install duckdb`), so you can put its time and memory next to the engine's own in the runs table.
170
+
171
+ ---
172
+
173
+ ## Benchmark: Python, Rust and DuckDB
174
+
175
+ The job: read two CSV files of 5 million rows, join them on a key, write the result (4.8 million rows) as CSV.
176
+
177
+ ![Median time and peak memory for the Python joins, the Rust joins and DuckDB](https://raw.githubusercontent.com/Ierofantis/streaming_sql_engine/master/docs/benchmark.svg)
178
+
179
+ Both files sorted by the key, 503 MB of input:
180
+
181
+ | Engine | Time | Peak memory |
182
+ |---|---|---|
183
+ | Python, file index join | 129 s | 194 MB |
184
+ | Python, in-memory hash join | 134 s | 4,089 MB |
185
+ | Python, merge join | 122 s | 68 MB |
186
+ | **Rust, file index join** | **1.6 s** | **95 MB** |
187
+ | **Rust, merge join** | **1.5 s** | **52 MB** |
188
+ | DuckDB 2.0.1 | 4.4 s | 1,208 MB |
189
+
190
+ Rust file index join against DuckDB on other data shapes (median of 5 runs):
191
+
192
+ | Data shape | Rust time | DuckDB time | Rust memory | DuckDB memory |
193
+ |---|---|---|---|---|
194
+ | File B shuffled | 2.4 s | 5.7 s | 99 MB | 1,254 MB |
195
+ | Both files shuffled | 2.1 s | 5.1 s | 97 MB | 1,280 MB |
196
+ | Both files sorted | 1.7 s | 4.2 s | 98 MB | 1,275 MB |
197
+ | Wide rows (2.4 GB input) | 9.6 s | 8.1 s | 106 MB | 2,301 MB |
198
+ | Repeated keys in B | 2.0 s | 4.7 s | 164 MB | 1,305 MB |
199
+ | Only 10% of rows match | 1.0 s | 2.7 s | 82 MB | 1,265 MB |
200
+
201
+ How to read this:
202
+
203
+ - **Machine:** a laptop with 4 physical / 8 logical cores and 32 GB RAM, Windows 11, Python 3.14. Rust and DuckDB use all 8 threads; the Python joins use one.
204
+ - **Method:** every run is a fresh process, the input files are already in the operating system's file cache, runs are interleaved, and the engines must produce the same result (row count, plus a checksum of the output for Rust and DuckDB). The Python joins were run once each; everything else is a median of 3 or 5 runs.
205
+ - **DuckDB reads the columns as text** here, as this engine does. With its own type detection it was up to 16% faster and used 6–26% less memory.
206
+ - **This is one job, not a general comparison.** DuckDB is a full analytical database; the Rust kernels do a two-file equality join on one key and copy bytes from input to output. On wide rows DuckDB is faster.
207
+ - **Not measured:** files larger than RAM, and machines with more cores.
208
+
209
+ Reproduce it (needs `duckdb`, `psutil` and the Rust extension):
210
+
211
+ ```bash
212
+ python benchmarks/bench_vs_duckdb.py --rows 5000000 # Rust and DuckDB, six data shapes
213
+ python benchmarks/bench_vs_duckdb.py --rows 5000000 --python --shapes shuffled,sorted
214
+ ```
215
+
216
+ Full reports: [Rust and DuckDB](benchmarks/results/rust-vs-duckdb-5m.md), [with the Python joins](benchmarks/results/python-rust-duckdb-5m.md).
217
+
218
+ ---
219
+
70
220
  ## The Problem: Data Lives Everywhere
71
221
 
72
222
  Modern applications don't store all their data in one place. You might have:
@@ -454,7 +604,7 @@ query = """
454
604
 
455
605
  ### 4. MMAP Join (For Large Files)
456
606
 
457
- Memory-mapped joins for files larger than RAM:
607
+ Memory-mapped joins for files larger than RAM. The `filename` can be a JSONL, CSV or TSV file; join keys are compared as text.
458
608
 
459
609
  ```python
460
610
  engine = Engine(use_polars=False) # MMAP requires use_polars=False