streaming-sql-engine 0.1.2__tar.gz → 0.1.4__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 (80) hide show
  1. streaming_sql_engine-0.1.4/MANIFEST.in +11 -0
  2. streaming_sql_engine-0.1.4/PKG-INFO +582 -0
  3. streaming_sql_engine-0.1.4/README.md +533 -0
  4. streaming_sql_engine-0.1.4/__init__.py +31 -0
  5. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/API_JOIN_OPERATIONS.md +0 -1
  6. streaming_sql_engine-0.1.4/documentation/ARCHITECTURAL_RECOMMENDATION.md +449 -0
  7. streaming_sql_engine-0.1.4/documentation/ARCHITECTURE_DECISION.md +329 -0
  8. streaming_sql_engine-0.1.4/documentation/ARCHITECTURE_SYNCED.md +77 -0
  9. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/BEST_USE_CASES.md +0 -1
  10. streaming_sql_engine-0.1.4/documentation/BETTER_FILTER_APPROACH.md +189 -0
  11. streaming_sql_engine-0.1.4/documentation/CHANGES_SUMMARY.md +240 -0
  12. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/COMPREHENSIVE_DOCUMENTATION.md +0 -1
  13. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/DEVELOPER_GUIDE.md +0 -1
  14. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/DUCKDB_COMPARISON.md +0 -1
  15. streaming_sql_engine-0.1.4/documentation/FINAL_IMPLEMENTATION_RECOMMENDATIONS.md +601 -0
  16. streaming_sql_engine-0.1.4/documentation/FINAL_RECOMMENDATION.md +406 -0
  17. streaming_sql_engine-0.1.4/documentation/HOW_PROTOCOL_DETECTION_WORKS.md +305 -0
  18. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/HOW_TO_ADD_TO_PROJECT.md +2 -3
  19. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/INSTALLATION.md +2 -3
  20. streaming_sql_engine-0.1.4/documentation/JSONL_EXECUTOR_ANALYSIS.md +232 -0
  21. streaming_sql_engine-0.1.4/documentation/JSONL_EXECUTOR_REMOVED.md +99 -0
  22. streaming_sql_engine-0.1.4/documentation/LIBRARY_DOCUMENTATION.md +495 -0
  23. streaming_sql_engine-0.1.4/documentation/MIGRATION_GUIDE.md +260 -0
  24. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/MULTI_SOURCE_EXAMPLE_README.md +0 -1
  25. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/MYSQL_USAGE.md +1 -2
  26. streaming_sql_engine-0.1.4/documentation/OPTIMIZATIONS_BREAKDOWN.md +294 -0
  27. streaming_sql_engine-0.1.4/documentation/OPTIMIZATIONS_NOT_DATABASE_ONLY.md +288 -0
  28. streaming_sql_engine-0.1.4/documentation/OPTIMIZATIONS_VS_POLARS.md +421 -0
  29. streaming_sql_engine-0.1.4/documentation/OPTIMIZER_AUTOMATED.md +175 -0
  30. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/PERFORMANCE.md +0 -1
  31. streaming_sql_engine-0.1.4/documentation/PERFORMANCE_COMPARISON.md +353 -0
  32. streaming_sql_engine-0.1.4/documentation/POLARS_AND_MMAP_GUIDE.md +329 -0
  33. streaming_sql_engine-0.1.4/documentation/PROTOCOL_AND_OPTIMIZATIONS_EXPLAINED.md +338 -0
  34. streaming_sql_engine-0.1.4/documentation/PROTOCOL_EXPLANATION.md +220 -0
  35. streaming_sql_engine-0.1.4/documentation/PUBLISHING.md +206 -0
  36. streaming_sql_engine-0.1.4/documentation/PYPI_CHECKLIST.md +148 -0
  37. streaming_sql_engine-0.1.4/documentation/QUICK_PUBLISH.md +88 -0
  38. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/QUICK_START.md +0 -1
  39. streaming_sql_engine-0.1.4/documentation/SIMPLE_PROTOCOL_GUIDE.md +251 -0
  40. streaming_sql_engine-0.1.4/documentation/SIMPLE_SOURCE_FUNCTIONS.md +135 -0
  41. streaming_sql_engine-0.1.4/documentation/SOURCE_COMBINATIONS_GUIDE.md +744 -0
  42. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/TECHNICAL_DOCUMENTATION.md +0 -1
  43. streaming_sql_engine-0.1.4/documentation/WHAT_IS_WHERE_TO_PARAMS.md +193 -0
  44. streaming_sql_engine-0.1.4/documentation/WHY_API_CONVERTER_NEEDED.md +220 -0
  45. streaming_sql_engine-0.1.4/documentation/WHY_MANUAL_PARSING.md +179 -0
  46. streaming_sql_engine-0.1.4/documentation/WHY_PROTOCOL_IN_SOURCES.md +251 -0
  47. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.4}/engine.py +123 -109
  48. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.4}/evaluator.py +218 -218
  49. streaming_sql_engine-0.1.4/executor.py +409 -0
  50. streaming_sql_engine-0.1.4/mmap_index.py +386 -0
  51. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.4}/operators.py +507 -479
  52. streaming_sql_engine-0.1.4/operators_mmap.py +269 -0
  53. streaming_sql_engine-0.1.4/operators_polars.py +581 -0
  54. streaming_sql_engine-0.1.4/optimizer.py +470 -0
  55. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.4}/planner.py +172 -156
  56. streaming_sql_engine-0.1.4/polars_expression_translator.py +177 -0
  57. streaming_sql_engine-0.1.4/polars_operators.py +280 -0
  58. streaming_sql_engine-0.1.4/protocol_helpers.py +493 -0
  59. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/pyproject.toml +23 -16
  60. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/requirements.txt +1 -1
  61. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/setup.py +25 -10
  62. streaming_sql_engine-0.1.4/streaming_sql_engine.egg-info/PKG-INFO +582 -0
  63. streaming_sql_engine-0.1.4/streaming_sql_engine.egg-info/SOURCES.txt +83 -0
  64. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/streaming_sql_engine.egg-info/requires.txt +13 -2
  65. streaming_sql_engine-0.1.2/LICENSE +0 -22
  66. streaming_sql_engine-0.1.2/MANIFEST.in +0 -13
  67. streaming_sql_engine-0.1.2/PKG-INFO +0 -418
  68. streaming_sql_engine-0.1.2/README.md +0 -378
  69. streaming_sql_engine-0.1.2/streaming_sql_engine/__init__.py +0 -30
  70. streaming_sql_engine-0.1.2/streaming_sql_engine/db_connector.py +0 -353
  71. streaming_sql_engine-0.1.2/streaming_sql_engine/executor.py +0 -133
  72. streaming_sql_engine-0.1.2/streaming_sql_engine/jsonl_executor.py +0 -393
  73. streaming_sql_engine-0.1.2/streaming_sql_engine.egg-info/PKG-INFO +0 -418
  74. streaming_sql_engine-0.1.2/streaming_sql_engine.egg-info/SOURCES.txt +0 -34
  75. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/APACHE_DRILL_COMPARISON.md +0 -0
  76. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/documentation/USER_GUIDE.md +0 -0
  77. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.4}/parser.py +0 -0
  78. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/setup.cfg +0 -0
  79. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/streaming_sql_engine.egg-info/dependency_links.txt +0 -0
  80. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.4}/streaming_sql_engine.egg-info/top_level.txt +0 -0
@@ -0,0 +1,11 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ include pyproject.toml
5
+ recursive-include documentation *.md
6
+ recursive-exclude examples *.jsonl
7
+ recursive-exclude examples *.csv
8
+ recursive-exclude examples __pycache__
9
+ recursive-exclude * __pycache__
10
+ recursive-exclude * *.pyc
11
+
@@ -0,0 +1,582 @@
1
+ Metadata-Version: 2.4
2
+ Name: streaming-sql-engine
3
+ Version: 0.1.4
4
+ Summary: A lightweight SQL execution engine for streaming row-by-row queries with joins across multiple data sources
5
+ Home-page: https://github.com/Ierofantis/streaming-sql-engine/tree/master
6
+ Author: Theodore Pantazopoulo
7
+ Author-email: Theodore Pantazopoulo <your.email@example.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/Ierofantis/streaming-sql-engine/tree/master
10
+ Project-URL: Repository, https://github.com/Ierofantis/streaming-sql-engine/tree/master
11
+ Project-URL: Issues, https://github.com/Ierofantis/streaming-sql-engine/issues
12
+ Project-URL: Documentation, https://github.com/Ierofantis/streaming-sql-engine/tree/master#readme
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
+ Provides-Extra: polars
29
+ Requires-Dist: polars>=0.19.0; extra == "polars"
30
+ Provides-Extra: db
31
+ Requires-Dist: psycopg2-binary>=2.9.0; extra == "db"
32
+ Requires-Dist: pymysql>=1.0.0; extra == "db"
33
+ Requires-Dist: DBUtils>=3.0.0; extra == "db"
34
+ Requires-Dist: pymongo>=4.0.0; extra == "db"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
37
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
38
+ Requires-Dist: black>=23.0.0; extra == "dev"
39
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
40
+ Provides-Extra: all
41
+ Requires-Dist: polars>=0.19.0; extra == "all"
42
+ Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
43
+ Requires-Dist: pymysql>=1.0.0; extra == "all"
44
+ Requires-Dist: DBUtils>=3.0.0; extra == "all"
45
+ Requires-Dist: pymongo>=4.0.0; extra == "all"
46
+ Dynamic: author
47
+ Dynamic: home-page
48
+ Dynamic: requires-python
49
+
50
+ # Streaming SQL Engine
51
+
52
+ A lightweight Python library that executes SQL queries **row-by-row** across **any data source** - databases, APIs, files, or custom Python functions. Join data from different systems using standard SQL syntax, without loading everything into memory.
53
+
54
+ ## 🎯 What It Does
55
+
56
+ **Execute SQL queries that join data from multiple sources:**
57
+
58
+ - ✅ **Databases** (PostgreSQL, MySQL, MongoDB)
59
+ - ✅ **REST APIs** (any HTTP endpoint)
60
+ - ✅ **Files** (JSONL, CSV, JSON)
61
+ - ✅ **Custom Python functions** (any iterator)
62
+
63
+ **All in one SQL query, streaming results row-by-row.**
64
+
65
+ ---
66
+
67
+ ## 🚀 Why It's Useful
68
+
69
+ ### Problem: You Can't Join Across Different Systems
70
+
71
+ **Traditional databases can't do this:**
72
+
73
+ ```python
74
+ # ❌ Can't join MySQL + PostgreSQL + REST API in one query
75
+ # ❌ Can't join database + CSV file
76
+ # ❌ Can't join API + JSON file
77
+ ```
78
+
79
+ **This library solves it:**
80
+
81
+ ```python
82
+ # ✅ Join MySQL + PostgreSQL + REST API + CSV file
83
+ # ✅ All in one SQL query
84
+ # ✅ Streams results row-by-row (low memory)
85
+ ```
86
+
87
+ ### Key Benefits
88
+
89
+ 1. **Cross-System Joins** - Join data from completely different sources
90
+ 2. **Memory Efficient** - Processes row-by-row, never loads full tables
91
+ 3. **Zero Infrastructure** - No clusters, no setup, just Python
92
+ 4. **Automatic Optimizations** - Filter pushdown, column pruning, vectorized operations
93
+ 5. **Simple API** - Standard SQL syntax, easy to use
94
+
95
+ ---
96
+
97
+ ## 📦 Installation
98
+
99
+ ```bash
100
+ pip install streaming-sql-engine
101
+ ```
102
+
103
+ **Or install from source:**
104
+
105
+ ```bash
106
+ git clone <repository>
107
+ cd streaming_sql_engine
108
+ pip install -e .
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 💡 Quick Start
114
+
115
+ ### Example 1: Simple Join
116
+
117
+ ```python
118
+ from streaming_sql_engine import Engine
119
+
120
+ # Create engine
121
+ engine = Engine()
122
+
123
+ # Register data sources (any Python iterators)
124
+ def users_source():
125
+ return iter([
126
+ {"id": 1, "name": "Alice", "dept_id": 10},
127
+ {"id": 2, "name": "Bob", "dept_id": 20},
128
+ ])
129
+
130
+ def departments_source():
131
+ return iter([
132
+ {"id": 10, "name": "Engineering"},
133
+ {"id": 20, "name": "Sales"},
134
+ ])
135
+
136
+ engine.register("users", users_source)
137
+ engine.register("departments", departments_source)
138
+
139
+ # Execute SQL query
140
+ query = """
141
+ SELECT users.name, departments.name AS dept
142
+ FROM users
143
+ JOIN departments ON users.dept_id = departments.id
144
+ """
145
+
146
+ for row in engine.query(query):
147
+ print(row)
148
+ # Output:
149
+ # {'users.name': 'Alice', 'departments.name': 'Engineering'}
150
+ # {'users.name': 'Bob', 'departments.name': 'Sales'}
151
+ ```
152
+
153
+ ### Example 2: Join Database + API + File
154
+
155
+ ```python
156
+ from streaming_sql_engine import Engine
157
+ from examples.database_helpers import create_table_source, create_pool_from_env
158
+ import requests
159
+ import json
160
+
161
+ engine = Engine()
162
+
163
+ # 1. Database source (PostgreSQL)
164
+ pool = create_pool_from_env()
165
+ engine.register(
166
+ "products",
167
+ create_table_source(pool, "products")
168
+ )
169
+
170
+ # 2. REST API source
171
+ def api_customers():
172
+ response = requests.get("https://api.example.com/customers")
173
+ for item in response.json():
174
+ yield item
175
+
176
+ engine.register("customers", api_customers)
177
+
178
+ # 3. JSONL file source
179
+ def file_orders():
180
+ with open("orders.jsonl") as f:
181
+ for line in f:
182
+ yield json.loads(line)
183
+
184
+ engine.register("orders", file_orders, filename="orders.jsonl")
185
+
186
+ # Join all three sources!
187
+ query = """
188
+ SELECT
189
+ products.name,
190
+ customers.email,
191
+ orders.quantity
192
+ FROM products
193
+ JOIN customers ON products.customer_id = customers.id
194
+ JOIN orders ON products.id = orders.product_id
195
+ WHERE products.price > 100
196
+ """
197
+
198
+ for row in engine.query(query):
199
+ print(row)
200
+ ```
201
+
202
+ ### Example 3: Simple Protocol Support (Automated!)
203
+
204
+ **Use helper functions - no manual implementation needed:**
205
+
206
+ ```python
207
+ from streaming_sql_engine import Engine
208
+ from streaming_sql_engine.protocol_helpers import (
209
+ register_file_source,
210
+ register_api_source,
211
+ )
212
+
213
+ engine = Engine()
214
+
215
+ # Register file sources with automatic protocol support
216
+ register_file_source(engine, "products", "data/products.jsonl")
217
+ register_file_source(engine, "categories", "data/categories.csv")
218
+
219
+ # Register API source with automatic protocol support
220
+ register_api_source(engine, "customers", "http://localhost:8000", "customers")
221
+
222
+ # Query with automatic optimizations (filter pushdown, column pruning)
223
+ for row in engine.query("""
224
+ SELECT products.name, categories.name AS category
225
+ FROM products
226
+ JOIN categories ON products.category_id = categories.id
227
+ WHERE products.price > 100
228
+ """):
229
+ print(row)
230
+ ```
231
+
232
+ **That's it!** No manual SQL parsing, no manual filtering - everything is automatic! 🎉
233
+
234
+ See [Simple Protocol Guide](documentation/SIMPLE_PROTOCOL_GUIDE.md) for more details.
235
+
236
+ ---
237
+
238
+ ## 🎯 Use Cases
239
+
240
+ ### ✅ Perfect For
241
+
242
+ 1. **Cross-System Data Integration**
243
+
244
+ - Join MySQL + PostgreSQL + MongoDB
245
+ - Join database + REST API
246
+ - Join API + CSV file
247
+
248
+ 2. **Real-Time Data Processing**
249
+
250
+ - Stream data from multiple sources
251
+ - Process row-by-row without buffering
252
+ - Low memory footprint
253
+
254
+ 3. **Data Pipeline ETL**
255
+
256
+ - Transform data from multiple sources
257
+ - Join before loading to destination
258
+ - Python-native processing
259
+
260
+ 4. **Microservices Data Aggregation**
261
+ - Join data from multiple services
262
+ - No shared database needed
263
+ - Simple Python integration
264
+
265
+ ### ❌ Not For
266
+
267
+ - **Single Database Queries** - Use direct SQL (10-100x faster)
268
+ - **Complex SQL** - GROUP BY, aggregations, subqueries not supported
269
+ - **Maximum Performance** - For same-database joins, use database directly
270
+
271
+ ---
272
+
273
+ ## 🔧 Features
274
+
275
+ ### Supported SQL
276
+
277
+ - ✅ **SELECT** - Column selection, aliasing
278
+ - ✅ **FROM** - Single table, aliases
279
+ - ✅ **JOIN** - INNER JOIN, LEFT JOIN
280
+ - ✅ **WHERE** - Comparisons, boolean logic, NULL checks, IN clauses
281
+ - ✅ **Table-qualified columns** - `table.column`
282
+
283
+ ### Not Supported
284
+
285
+ - ❌ GROUP BY, aggregations
286
+ - ❌ ORDER BY
287
+ - ❌ HAVING
288
+ - ❌ UNION
289
+ - ❌ Subqueries
290
+ - ❌ Non-equality joins
291
+
292
+ ---
293
+
294
+ ## ⚡ Performance Optimizations
295
+
296
+ ### 1. Protocol-Based Optimizations (Automatic)
297
+
298
+ **Filter Pushdown** - Push WHERE clauses to data sources:
299
+
300
+ ```python
301
+ # Engine automatically passes WHERE clause to source
302
+ def source(dynamic_where=None, dynamic_columns=None):
303
+ query = f"SELECT * FROM table WHERE {dynamic_where}"
304
+ # Source filters before returning data
305
+ ```
306
+
307
+ **Column Pruning** - Only request needed columns:
308
+
309
+ ```python
310
+ # Engine automatically requests only needed columns
311
+ def source(dynamic_where=None, dynamic_columns=None):
312
+ columns = ", ".join(dynamic_columns) # Only requested columns
313
+ query = f"SELECT {columns} FROM table"
314
+ ```
315
+
316
+ **How it works:** Engine detects if your source function accepts `dynamic_where`/`dynamic_columns` parameters automatically. No flags needed!
317
+
318
+ **💡 Tip:** Use helper functions to automate protocol support - see [Simple Protocol Guide](documentation/SIMPLE_PROTOCOL_GUIDE.md)!
319
+
320
+ ### 2. Polars Vectorization (Automatic)
321
+
322
+ **10-200x faster** for large datasets:
323
+
324
+ - Vectorized filtering (SIMD-accelerated)
325
+ - Vectorized projections
326
+ - Batch processing
327
+
328
+ Enabled by default. Disable with:
329
+
330
+ ```python
331
+ engine = Engine(use_polars=False)
332
+ ```
333
+
334
+ ### 3. Memory-Mapped Joins (For Files)
335
+
336
+ **90-99% memory reduction** for large JSONL files:
337
+
338
+ ```python
339
+ engine.register(
340
+ "products",
341
+ lambda: read_jsonl("products.jsonl"),
342
+ filename="products.jsonl" # Enables mmap joins
343
+ )
344
+ ```
345
+
346
+ ### 4. Merge Joins (For Sorted Data)
347
+
348
+ **Efficient joins** when both sides are sorted:
349
+
350
+ ```python
351
+ engine.register(
352
+ "users",
353
+ users_source,
354
+ ordered_by="id" # Enables merge join
355
+ )
356
+ ```
357
+
358
+ ---
359
+
360
+ ## 📚 Examples
361
+
362
+ ### Database + Database
363
+
364
+ ```python
365
+ from examples.database_helpers import create_table_source, create_pool_from_env
366
+
367
+ # PostgreSQL
368
+ pg_pool = create_postgresql_pool_from_env()
369
+ engine.register("pg_users", create_table_source(pg_pool, "users"))
370
+
371
+ # MySQL
372
+ mysql_pool = create_mysql_pool_from_env()
373
+ engine.register("mysql_orders", create_table_source(mysql_pool, "orders"))
374
+
375
+ # Join across databases!
376
+ query = """
377
+ SELECT pg_users.name, mysql_orders.total
378
+ FROM pg_users
379
+ JOIN mysql_orders ON pg_users.id = mysql_orders.user_id
380
+ """
381
+ ```
382
+
383
+ ### Database + REST API
384
+
385
+ ```python
386
+ import requests
387
+
388
+ def api_products():
389
+ response = requests.get("https://api.example.com/products")
390
+ return iter(response.json())
391
+
392
+ engine.register("api_products", api_products)
393
+ engine.register("db_orders", create_table_source(pool, "orders"))
394
+
395
+ query = """
396
+ SELECT api_products.name, db_orders.quantity
397
+ FROM api_products
398
+ JOIN db_orders ON api_products.id = db_orders.product_id
399
+ """
400
+ ```
401
+
402
+ ### File + File
403
+
404
+ ```python
405
+ def read_jsonl(filename):
406
+ with open(filename) as f:
407
+ for line in f:
408
+ yield json.loads(line)
409
+
410
+ engine.register("products", lambda: read_jsonl("products.jsonl"), filename="products.jsonl")
411
+ engine.register("images", lambda: read_jsonl("images.jsonl"), filename="images.jsonl")
412
+
413
+ query = """
414
+ SELECT products.name, images.url
415
+ FROM products
416
+ JOIN images ON products.id = images.product_id
417
+ """
418
+ ```
419
+
420
+ ---
421
+
422
+ ## 🏗️ Architecture
423
+
424
+ ### How It Works
425
+
426
+ ```
427
+ SQL Query
428
+ ↓
429
+ Parser (sqlglot) → AST
430
+ ↓
431
+ Planner → Logical Plan
432
+ ↓
433
+ Optimizer → Optimized Plan (column pruning, filter pushdown)
434
+ ↓
435
+ Executor → Iterator Pipeline
436
+ ↓
437
+ Results (Generator) → Row-by-row streaming
438
+ ```
439
+
440
+ ### Iterator Pipeline
441
+
442
+ ```
443
+ ScanIterator → FilterIterator → JoinIterators → ProjectIterator
444
+ ```
445
+
446
+ Each iterator processes rows incrementally, never loading full tables.
447
+
448
+ ---
449
+
450
+ ## 🔍 Debug Mode
451
+
452
+ Enable debug output to see execution details:
453
+
454
+ ```python
455
+ engine = Engine(debug=True)
456
+
457
+ for row in engine.query("SELECT * FROM users"):
458
+ print(row)
459
+ ```
460
+
461
+ **Output:**
462
+
463
+ ```
464
+ ============================================================
465
+ STREAMING SQL ENGINE - DEBUG MODE
466
+ ============================================================
467
+
468
+ [1/3] PARSING SQL QUERY...
469
+ ✓ SQL parsed successfully
470
+
471
+ [2/3] BUILDING LOGICAL PLAN...
472
+ ✓ Logical plan built:
473
+ - Root table: users
474
+ - Joins: 1
475
+ - WHERE clause: Yes
476
+ - Projections: 2
477
+
478
+ [3/3] EXECUTING QUERY...
479
+ [OPTIMIZATION] Source supports protocol - applying column pruning
480
+ [SCAN] Scanning table: users
481
+ [JOIN] INNER JOIN orders
482
+ [PROJECT] Applying SELECT projection
483
+ ```
484
+
485
+ ---
486
+
487
+ ## 📖 Documentation
488
+
489
+ - **[Quick Start Guide](documentation/QUICK_START.md)** - Get started in 5 minutes
490
+ - **[User Guide](documentation/USER_GUIDE.md)** - Complete usage guide
491
+ - **[Best Use Cases](documentation/BEST_USE_CASES.md)** - When to use this library
492
+ - **[Performance Guide](documentation/PERFORMANCE.md)** - Performance tips and benchmarks
493
+ - **[Migration Guide](documentation/MIGRATION_GUIDE.md)** - Upgrading from older versions
494
+ - **[Developer Guide](documentation/DEVELOPER_GUIDE.md)** - Contributing and extending
495
+
496
+ ---
497
+
498
+ ## 🎓 Key Concepts
499
+
500
+ ### Protocol-Based Optimization
501
+
502
+ **No flags needed!** The engine automatically detects if your source supports optimizations:
503
+
504
+ ```python
505
+ # Simple source (no optimizations)
506
+ def simple_source():
507
+ return iter([...])
508
+
509
+ # Optimized source (with protocol)
510
+ def optimized_source(dynamic_where=None, dynamic_columns=None):
511
+ # Engine automatically passes optimization parameters
512
+ ...
513
+ ```
514
+
515
+ ### Streaming Execution
516
+
517
+ **Row-by-row processing:**
518
+
519
+ - Results are yielded immediately as they're produced
520
+ - Never loads full tables into memory
521
+ - Perfect for large datasets
522
+
523
+ ### Cross-Source Joins
524
+
525
+ **Join any data sources:**
526
+
527
+ - Databases (PostgreSQL, MySQL, MongoDB)
528
+ - APIs (REST, GraphQL, any HTTP endpoint)
529
+ - Files (JSONL, CSV, JSON)
530
+ - Custom Python functions
531
+
532
+ ---
533
+
534
+ ## 🤝 Contributing
535
+
536
+ Contributions welcome! See [Developer Guide](documentation/DEVELOPER_GUIDE.md) for details.
537
+
538
+ ---
539
+
540
+ ## 📄 License
541
+
542
+ MIT
543
+
544
+ ---
545
+
546
+ ## 🙋 FAQ
547
+
548
+ **Q: Can I join data from different databases?**
549
+ A: Yes! That's the main use case. Join MySQL + PostgreSQL + MongoDB in one query.
550
+
551
+ **Q: Is it faster than database queries?**
552
+ A: No. For same-database queries, use direct SQL (10-100x faster). This library is for cross-system joins.
553
+
554
+ **Q: Does it support GROUP BY?**
555
+ A: No. Use a database for aggregations. This library focuses on joins and filtering.
556
+
557
+ **Q: How does it handle large datasets?**
558
+ A: Streams row-by-row, uses memory-mapped files for large JSONL files, and Polars for vectorized operations.
559
+
560
+ **Q: Can I use it with APIs?**
561
+ A: Yes! Any Python function that returns an iterator works. Perfect for REST APIs.
562
+
563
+ ---
564
+
565
+ ## ⭐ Why Use This?
566
+
567
+ **Use this library when:**
568
+
569
+ - ✅ You need to join data from different systems
570
+ - ✅ You want to process data row-by-row (low memory)
571
+ - ✅ You need Python-native data processing
572
+ - ✅ You want simple SQL syntax for complex data integration
573
+
574
+ **Don't use this library when:**
575
+
576
+ - ❌ All data is in the same database (use direct SQL)
577
+ - ❌ You need GROUP BY or aggregations (use database)
578
+ - ❌ You need maximum performance for same-database queries (use database)
579
+
580
+ ---
581
+
582
+ **Ready to get started?** Check out the [Quick Start Guide](documentation/QUICK_START.md)!