streaming-sql-engine 0.1.2__tar.gz → 0.1.3__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 (51) hide show
  1. {streaming_sql_engine-0.1.2/streaming_sql_engine.egg-info → streaming_sql_engine-0.1.3}/PKG-INFO +55 -153
  2. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/README.md +275 -378
  3. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/__init__.py +1 -1
  4. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/db_connector.py +30 -6
  5. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/API_JOIN_OPERATIONS.md +0 -1
  6. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/BEST_USE_CASES.md +0 -1
  7. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/COMPREHENSIVE_DOCUMENTATION.md +0 -1
  8. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/DEVELOPER_GUIDE.md +0 -1
  9. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/DUCKDB_COMPARISON.md +0 -1
  10. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/HOW_TO_ADD_TO_PROJECT.md +2 -3
  11. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/INSTALLATION.md +2 -3
  12. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/MULTI_SOURCE_EXAMPLE_README.md +0 -1
  13. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/MYSQL_USAGE.md +1 -2
  14. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/PERFORMANCE.md +0 -1
  15. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/QUICK_START.md +0 -1
  16. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/TECHNICAL_DOCUMENTATION.md +0 -1
  17. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/engine.py +119 -109
  18. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/evaluator.py +218 -218
  19. streaming_sql_engine-0.1.3/executor.py +318 -0
  20. streaming_sql_engine-0.1.3/mmap_index.py +386 -0
  21. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/operators.py +507 -479
  22. streaming_sql_engine-0.1.3/operators_mmap.py +269 -0
  23. streaming_sql_engine-0.1.3/operators_polars.py +581 -0
  24. streaming_sql_engine-0.1.3/optimizer.py +349 -0
  25. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/planner.py +172 -156
  26. streaming_sql_engine-0.1.3/polars_expression_translator.py +177 -0
  27. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/pyproject.toml +12 -10
  28. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/requirements.txt +1 -1
  29. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/setup.py +10 -9
  30. streaming_sql_engine-0.1.3/streaming_sql_engine/__init__.py +36 -0
  31. streaming_sql_engine-0.1.3/streaming_sql_engine/db_connector.py +594 -0
  32. streaming_sql_engine-0.1.3/streaming_sql_engine/engine.py +119 -0
  33. streaming_sql_engine-0.1.3/streaming_sql_engine/evaluator.py +218 -0
  34. streaming_sql_engine-0.1.3/streaming_sql_engine/executor.py +318 -0
  35. streaming_sql_engine-0.1.3/streaming_sql_engine/jsonl_executor.py +393 -0
  36. streaming_sql_engine-0.1.3/streaming_sql_engine/operators.py +507 -0
  37. streaming_sql_engine-0.1.3/streaming_sql_engine/parser.py +93 -0
  38. streaming_sql_engine-0.1.3/streaming_sql_engine/planner.py +172 -0
  39. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3/streaming_sql_engine.egg-info}/PKG-INFO +55 -153
  40. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/streaming_sql_engine.egg-info/SOURCES.txt +28 -2
  41. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/streaming_sql_engine.egg-info/requires.txt +6 -0
  42. streaming_sql_engine-0.1.2/LICENSE +0 -22
  43. streaming_sql_engine-0.1.2/MANIFEST.in +0 -13
  44. streaming_sql_engine-0.1.2/streaming_sql_engine/executor.py +0 -133
  45. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/APACHE_DRILL_COMPARISON.md +0 -0
  46. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/documentation/USER_GUIDE.md +0 -0
  47. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/jsonl_executor.py +0 -0
  48. {streaming_sql_engine-0.1.2/streaming_sql_engine → streaming_sql_engine-0.1.3}/parser.py +0 -0
  49. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/setup.cfg +0 -0
  50. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/streaming_sql_engine.egg-info/dependency_links.txt +0 -0
  51. {streaming_sql_engine-0.1.2 → streaming_sql_engine-0.1.3}/streaming_sql_engine.egg-info/top_level.txt +0 -0
@@ -1,14 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streaming-sql-engine
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: A lightweight SQL execution engine for streaming row-by-row queries with joins
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
5
+ Home-page: https://github.com/Ierofantis/streaming-sql-engine/tree/master
6
+ Author: Your Name
7
+ Author-email: Your Name <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
10
11
  Project-URL: Issues, https://github.com/Ierofantis/streaming-sql-engine/issues
11
- Project-URL: Documentation, https://github.com/Ierofantis/streaming-sql-engine
12
+ Project-URL: Documentation, https://github.com/Ierofantis/streaming-sql-engine/tree/master#readme
12
13
  Keywords: sql,streaming,join,database,query,engine
13
14
  Classifier: Development Status :: 3 - Alpha
14
15
  Classifier: Intended Audience :: Developers
@@ -34,6 +35,10 @@ Requires-Dist: pytest>=7.0.0; extra == "dev"
34
35
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
35
36
  Requires-Dist: black>=23.0.0; extra == "dev"
36
37
  Requires-Dist: flake8>=6.0.0; extra == "dev"
38
+ Provides-Extra: mongodb
39
+ Requires-Dist: pymongo>=4.0.0; extra == "mongodb"
40
+ Provides-Extra: polars
41
+ Requires-Dist: polars>=0.19.0; extra == "polars"
37
42
  Dynamic: author
38
43
  Dynamic: home-page
39
44
  Dynamic: requires-python
@@ -42,77 +47,6 @@ Dynamic: requires-python
42
47
 
43
48
  A lightweight Python library for executing SQL queries with joins in a streaming, row-by-row fashion without loading full tables into memory.
44
49
 
45
- ## What This Library Does
46
-
47
- **Streaming SQL Join Engine** is a Python library that lets you write SQL queries to join data from **any source** - CSV files, REST APIs, database tables, JSON files, or custom Python functions - **without copying or loading the data into a database first**.
48
-
49
- ### The Core Problem It Solves
50
-
51
- Traditionally, to join data from different sources (like multiple APIs, CSV files, or databases), you need to:
52
-
53
- 1. Extract data from each source
54
- 2. Load it into a database or data warehouse
55
- 3. Write SQL queries against that database
56
- 4. Export the results
57
-
58
- This library eliminates steps 2 and 4. You can write SQL queries directly against your original data sources, and the engine processes them row-by-row in memory, streaming results as they're computed.
59
-
60
- ### How It Works
61
-
62
- 1. **Register Data Sources**: You register any Python function that yields dictionaries (rows) as a "table":
63
-
64
- ```python
65
- def my_api_source():
66
- response = requests.get("https://api.example.com/data")
67
- for item in response.json():
68
- yield {"id": item["id"], "name": item["name"]}
69
-
70
- engine.register("my_table", my_api_source)
71
- ```
72
-
73
- 2. **Write SQL Queries**: Use standard SQL syntax to join and filter:
74
-
75
- ```python
76
- query = """
77
- SELECT t1.name, t2.value
78
- FROM table1 t1
79
- JOIN table2 t2 ON t1.id = t2.id
80
- WHERE t1.status = 'active'
81
- """
82
- ```
83
-
84
- 3. **Stream Results**: The engine processes your query row-by-row, yielding results as they're computed:
85
- ```python
86
- for row in engine.query(query):
87
- print(row) # Process each row immediately, no waiting for full result set
88
- ```
89
-
90
- ### Key Characteristics
91
-
92
- - **No Data Copying**: Data stays in its original source (API, file, database). Only the data needed for joins is temporarily cached.
93
- - **Memory Efficient**: Uses iterator pipelines - processes one row at a time instead of loading entire tables.
94
- - **Source Agnostic**: Works with any data source you can write a Python function for (APIs, CSVs, databases, JSON files, etc.).
95
- - **SQL Interface**: Familiar SQL syntax for joins and filtering, even when joining data from completely different systems.
96
- - **Streaming Execution**: Results are yielded immediately as they're computed, enabling real-time processing of large datasets.
97
-
98
- ### Use Cases
99
-
100
- - **API Data Integration**: Join data from multiple REST APIs without setting up a database
101
- - **File Processing**: Join CSV files, JSON files, or other file formats using SQL
102
- - **Cross-System Queries**: Query data from PostgreSQL, MySQL, APIs, and files in a single SQL query
103
- - **Real-Time Analytics**: Process streaming data sources with SQL joins
104
- - **ETL Simplification**: Replace complex ETL pipelines with simple SQL queries
105
- - **Prototyping**: Quickly explore relationships between different data sources
106
-
107
- ### What Makes It Different
108
-
109
- Unlike traditional databases or query engines:
110
-
111
- - **No setup required**: No database server, no schema creation, no data loading
112
- - **Works with live data**: Queries execute against current data from APIs or files
113
- - **Minimal memory footprint**: Only caches what's needed for joins, not entire tables
114
- - **Python-native**: Integrates seamlessly with Python code and data sources
115
-
116
50
  ## Features
117
51
 
118
52
  - **Streaming execution**: Processes queries row-by-row using Python generators
@@ -161,7 +95,7 @@ from streaming_sql_engine import Engine
161
95
  If the library is hosted on GitHub or another Git repository:
162
96
 
163
97
  ```bash
164
- pip install git+https://github.com/Ierofantis/streaming-sql-engine.git
98
+ pip install git+https://github.com/yourusername/streaming-sql-engine.git
165
99
  ```
166
100
 
167
101
  ### Option 4: Install as a Package in Your Project
@@ -256,73 +190,6 @@ for row in engine.query(query):
256
190
  # {'name': 'Charlie', 'dept_name': 'Engineering'}
257
191
  ```
258
192
 
259
- ## Real-World Example: Joining Multiple APIs
260
-
261
- Join data from multiple free public APIs using SQL:
262
-
263
- ```python
264
- # Install: pip install streaming-sql-engine
265
- import requests
266
- from streaming_sql_engine import Engine
267
-
268
- # Define API sources
269
- def jsonplaceholder_users_api():
270
- """Fetch users from JSONPlaceholder API."""
271
- response = requests.get("https://jsonplaceholder.typicode.com/users")
272
- for user in response.json():
273
- yield {
274
- "user_id": user["id"],
275
- "user_name": user["name"],
276
- "user_email": user["email"],
277
- "user_city": user["address"]["city"],
278
- }
279
-
280
- def jsonplaceholder_posts_api():
281
- """Fetch posts from JSONPlaceholder API."""
282
- response = requests.get("https://jsonplaceholder.typicode.com/posts")
283
- for post in response.json():
284
- yield {
285
- "post_id": post["id"],
286
- "user_id": post["userId"],
287
- "post_title": post["title"],
288
- "post_body": post["body"][:100],
289
- }
290
-
291
- def rest_countries_api():
292
- """Fetch countries from REST Countries API."""
293
- response = requests.get("https://restcountries.com/v3.1/all")
294
- for country in response.json():
295
- yield {
296
- "country_code": country.get("cca2", ""),
297
- "country_name": country["name"].get("common", ""),
298
- "capital": country.get("capital", ["N/A"])[0] if country.get("capital") else "N/A",
299
- "population": country.get("population", 0),
300
- }
301
-
302
- # Create engine and register sources
303
- engine = Engine()
304
- engine.register("users", jsonplaceholder_users_api)
305
- engine.register("posts", jsonplaceholder_posts_api)
306
- engine.register("countries", rest_countries_api)
307
-
308
- # Join Users + Posts from different APIs
309
- query = """
310
- SELECT
311
- users.user_name,
312
- users.user_email,
313
- posts.post_title,
314
- posts.post_body
315
- FROM users
316
- JOIN posts ON users.user_id = posts.user_id
317
- WHERE users.user_id <= 3
318
- """
319
-
320
- for row in engine.query(query):
321
- print(f"{row['user_name']} ({row['user_email']}): {row['post_title']}")
322
- ```
323
-
324
- This example demonstrates joining data from multiple REST APIs using standard SQL syntax - no ETL, no data copying, just pure SQL joins across different data sources!
325
-
326
193
  ## Supported SQL Features
327
194
 
328
195
  ### SELECT
@@ -376,6 +243,40 @@ engine.register(
376
243
  )
377
244
  ```
378
245
 
246
+ ## Performance Optimizations
247
+
248
+ ### Memory-Efficient Joins
249
+
250
+ For file-based sources, use `filename` parameter to enable memory-mapped joins (90-99% memory reduction):
251
+
252
+ ```python
253
+ engine.register(
254
+ "images",
255
+ lambda: load_jsonl_file("images.jsonl"),
256
+ filename="images.jsonl" # Enables mmap-based joins
257
+ )
258
+ ```
259
+
260
+ ### Database Filter Pushdown
261
+
262
+ For database sources, use `is_database_source=True` to enable filter pushdown:
263
+
264
+ ```python
265
+ engine.register(
266
+ "products",
267
+ create_table_source(pool, "products"),
268
+ is_database_source=True # Enables WHERE clause pushdown
269
+ )
270
+ ```
271
+
272
+ ### Polars Acceleration
273
+
274
+ Polars optimizations are enabled by default. Disable with:
275
+
276
+ ```python
277
+ engine = Engine(use_polars=False) # Disable Polars optimizations
278
+ ```
279
+
379
280
  ## Architecture
380
281
 
381
282
  The engine follows a pipeline architecture:
@@ -405,14 +306,15 @@ The engine raises clear exceptions for:
405
306
  - **Streaming**: Results are yielded as soon as they're produced
406
307
  - **No buffering**: Intermediate results are not fully materialized
407
308
 
408
- ## Installation from PyPI
309
+ ## Documentation
409
310
 
410
- Once published, you can install the package directly from PyPI:
411
-
412
- ```bash
413
- pip install streaming-sql-engine
414
- ```
311
+ - **[TECHNICAL_DOCUMENTATION.md](TECHNICAL_DOCUMENTATION.md)**: Complete technical documentation explaining architecture, algorithms, and design decisions
312
+ - **[DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md)**: Guide for developers who want to understand, modify, or extend the codebase
313
+ - **[PERFORMANCE.md](PERFORMANCE.md)**: Performance comparison with database joins and optimization tips
314
+ - **[MYSQL_USAGE.md](MYSQL_USAGE.md)**: MySQL-specific usage guide
315
+ - **[QUICK_START.md](QUICK_START.md)**: Quick start guide for new users
316
+ - **[INSTALLATION.md](INSTALLATION.md)**: Detailed installation instructions
415
317
 
416
318
  ## License
417
319
 
418
- MIT License
320
+ MIT