streaming-sql-engine 0.1.12__tar.gz → 0.1.13__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 (79) hide show
  1. {streaming_sql_engine-0.1.12/streaming_sql_engine.egg-info → streaming_sql_engine-0.1.13}/PKG-INFO +1 -1
  2. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/__init__.py +1 -1
  3. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/executor.py +17 -8
  4. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/operators_polars.py +32 -4
  5. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/pyproject.toml +1 -1
  6. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/setup.py +1 -1
  7. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13/streaming_sql_engine.egg-info}/PKG-INFO +1 -1
  8. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/DEPLOYMENT.md +0 -0
  9. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/MANIFEST.in +0 -0
  10. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/QUICK_DEPLOY.md +0 -0
  11. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/QUICK_FIX.md +0 -0
  12. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/README.md +0 -0
  13. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/APACHE_DRILL_COMPARISON.md +0 -0
  14. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/API_JOIN_OPERATIONS.md +0 -0
  15. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/ARCHITECTURAL_RECOMMENDATION.md +0 -0
  16. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/ARCHITECTURE_DECISION.md +0 -0
  17. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/ARCHITECTURE_SYNCED.md +0 -0
  18. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/BEST_USE_CASES.md +0 -0
  19. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/BETTER_FILTER_APPROACH.md +0 -0
  20. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/CHANGES_SUMMARY.md +0 -0
  21. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/COMPREHENSIVE_ARTICLE.md +0 -0
  22. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/COMPREHENSIVE_DOCUMENTATION.md +0 -0
  23. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/DEVELOPER_GUIDE.md +0 -0
  24. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/DUCKDB_COMPARISON.md +0 -0
  25. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/FINAL_IMPLEMENTATION_RECOMMENDATIONS.md +0 -0
  26. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/FINAL_RECOMMENDATION.md +0 -0
  27. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/FIRST_MATCH_ONLY_WARNINGS.md +0 -0
  28. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/HOW_PROTOCOL_DETECTION_WORKS.md +0 -0
  29. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/HOW_TO_ADD_TO_PROJECT.md +0 -0
  30. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/INSTALLATION.md +0 -0
  31. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/JSONL_EXECUTOR_ANALYSIS.md +0 -0
  32. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/JSONL_EXECUTOR_REMOVED.md +0 -0
  33. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/LIBRARY_DOCUMENTATION.md +0 -0
  34. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/MEDIUM_ARTICLE.md +0 -0
  35. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/MIGRATION_GUIDE.md +0 -0
  36. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/MULTI_SOURCE_EXAMPLE_README.md +0 -0
  37. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/MYSQL_USAGE.md +0 -0
  38. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/OPTIMIZATIONS_BREAKDOWN.md +0 -0
  39. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/OPTIMIZATIONS_NOT_DATABASE_ONLY.md +0 -0
  40. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/OPTIMIZATIONS_VS_POLARS.md +0 -0
  41. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/OPTIMIZER_AUTOMATED.md +0 -0
  42. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/PERFORMANCE.md +0 -0
  43. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/PERFORMANCE_COMPARISON.md +0 -0
  44. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/POLARS_AND_MMAP_GUIDE.md +0 -0
  45. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/PROTOCOL_AND_OPTIMIZATIONS_EXPLAINED.md +0 -0
  46. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/PROTOCOL_EXPLANATION.md +0 -0
  47. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/PUBLISHING.md +0 -0
  48. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/PYPI_CHECKLIST.md +0 -0
  49. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/QUICK_PUBLISH.md +0 -0
  50. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/QUICK_START.md +0 -0
  51. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/SIMPLE_PROTOCOL_GUIDE.md +0 -0
  52. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/SIMPLE_SOURCE_FUNCTIONS.md +0 -0
  53. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/SOURCE_COMBINATIONS_GUIDE.md +0 -0
  54. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/TECHNICAL_DOCUMENTATION.md +0 -0
  55. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/USER_GUIDE.md +0 -0
  56. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/WHAT_IS_WHERE_TO_PARAMS.md +0 -0
  57. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/WHEN_POLARS_IS_USED.md +0 -0
  58. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/WHY_API_CONVERTER_NEEDED.md +0 -0
  59. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/WHY_MANUAL_PARSING.md +0 -0
  60. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/WHY_ORIGINAL_IS_FASTER.md +0 -0
  61. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/WHY_PROTOCOL_IN_SOURCES.md +0 -0
  62. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/documentation/XML_MONGO_USE_CASE.md +0 -0
  63. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/engine.py +0 -0
  64. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/evaluator.py +0 -0
  65. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/mmap_index.py +0 -0
  66. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/operators.py +0 -0
  67. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/operators_mmap.py +0 -0
  68. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/optimizer.py +0 -0
  69. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/parser.py +0 -0
  70. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/planner.py +0 -0
  71. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/polars_expression_translator.py +0 -0
  72. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/polars_operators.py +0 -0
  73. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/protocol_helpers.py +0 -0
  74. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/requirements.txt +0 -0
  75. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/setup.cfg +0 -0
  76. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/streaming_sql_engine.egg-info/SOURCES.txt +0 -0
  77. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/streaming_sql_engine.egg-info/dependency_links.txt +0 -0
  78. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/streaming_sql_engine.egg-info/requires.txt +0 -0
  79. {streaming_sql_engine-0.1.12 → streaming_sql_engine-0.1.13}/streaming_sql_engine.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streaming-sql-engine
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: A lightweight SQL execution engine for streaming row-by-row queries with joins across multiple data sources
5
5
  Home-page: https://github.com/Ierofantis/streaming-sql-engine/tree/master
6
6
  Author: Theodore Pantazopoulo
@@ -27,5 +27,5 @@ try:
27
27
  except ImportError:
28
28
  __all__ = ["Engine"]
29
29
 
30
- __version__ = "0.1.12"
30
+ __version__ = "0.1.13"
31
31
 
@@ -307,7 +307,8 @@ def _build_join_iterator(
307
307
 
308
308
  if use_merge_join:
309
309
  if debug:
310
- print(f" Using MERGE JOIN (sorted data)")
310
+ iterator_type = "MERGE JOIN"
311
+ print(f" Using {iterator_type} (sorted data)")
311
312
  return MergeJoinIterator(
312
313
  left_iterator,
313
314
  right_source,
@@ -327,10 +328,11 @@ def _build_join_iterator(
327
328
  if (MMAP_AVAILABLE and MmapLookupJoinIterator is not None and
328
329
  right_table_filename):
329
330
  if debug:
331
+ iterator_type = "MMAP LOOKUP JOIN"
330
332
  if required_columns:
331
- print(f" Using MMAP LOOKUP JOIN (low memory, columns: {len(required_columns)})...")
333
+ print(f" Using {iterator_type} (low memory, columns: {len(required_columns)})...")
332
334
  else:
333
- print(f" Using MMAP LOOKUP JOIN (low memory, position-based index)...")
335
+ print(f" Using {iterator_type} (low memory, position-based index)...")
334
336
  try:
335
337
  return MmapLookupJoinIterator(
336
338
  left_iterator,
@@ -358,10 +360,13 @@ def _build_join_iterator(
358
360
  if (use_polars and POLARS_AVAILABLE and
359
361
  should_use_polars(right_source, threshold=10000)):
360
362
  if debug:
363
+ iterator_type = "POLARS LOOKUP JOIN"
361
364
  if required_columns:
362
- print(f" Using POLARS LOOKUP JOIN (fast, columns: {len(required_columns)})...")
365
+ print(f" Using {iterator_type} (fast, columns: {len(required_columns)})...")
363
366
  else:
364
- print(f" Using POLARS LOOKUP JOIN (fast, vectorized)...")
367
+ print(f" Using {iterator_type} (fast, vectorized)...")
368
+ if first_match_only:
369
+ print(f" ⚡ First-match-only mode enabled")
365
370
  try:
366
371
  return PolarsLookupJoinIterator(
367
372
  left_iterator,
@@ -373,7 +378,8 @@ def _build_join_iterator(
373
378
  join_info.alias,
374
379
  batch_size=10000,
375
380
  required_columns=required_columns,
376
- debug=debug
381
+ debug=debug,
382
+ first_match_only=first_match_only
377
383
  )
378
384
  except Exception as e:
379
385
  if debug:
@@ -382,10 +388,13 @@ def _build_join_iterator(
382
388
  pass
383
389
 
384
390
  if debug:
391
+ iterator_type = "LOOKUP JOIN (Python)"
385
392
  if required_columns:
386
- print(f" Using LOOKUP JOIN (building index, columns: {len(required_columns)})...")
393
+ print(f" Using {iterator_type} (building index, columns: {len(required_columns)})...")
387
394
  else:
388
- print(f" Using LOOKUP JOIN (building index...)")
395
+ print(f" Using {iterator_type} (building index...)")
396
+ if first_match_only:
397
+ print(f" ⚡ First-match-only mode enabled")
389
398
  return LookupJoinIterator(
390
399
  left_iterator,
391
400
  right_source,
@@ -32,7 +32,8 @@ class PolarsLookupJoinIterator:
32
32
  right_alias: str,
33
33
  batch_size: int = 10000,
34
34
  required_columns: Optional[Set[str]] = None,
35
- debug: bool = False
35
+ debug: bool = False,
36
+ first_match_only: bool = False
36
37
  ):
37
38
  self.left_source = left_source
38
39
  self.right_source_fn = right_source_fn
@@ -44,6 +45,7 @@ class PolarsLookupJoinIterator:
44
45
  self.batch_size = batch_size
45
46
  self.required_columns = required_columns # Set of column names (for column pruning)
46
47
  self.debug = debug
48
+ self.first_match_only = first_match_only # If True, only return first match per left key
47
49
 
48
50
  # Extract column name from right key (e.g., "alias.col" -> "col")
49
51
  self.right_table_col = self._extract_column_from_key(right_key)
@@ -51,6 +53,8 @@ class PolarsLookupJoinIterator:
51
53
  # Build Polars-based lookup index (SIMD-accelerated)
52
54
  if self.debug:
53
55
  print(f" Building Polars lookup index for {right_table}...")
56
+ if first_match_only:
57
+ print(f" ⚡ First-match-only mode: Will deduplicate right side and return only first match per left key")
54
58
  self._build_polars_index()
55
59
 
56
60
  # State for join iteration
@@ -140,16 +144,24 @@ class PolarsLookupJoinIterator:
140
144
  self.lookup_index = {}
141
145
 
142
146
  # Iterate through groups (Polars does this efficiently with SIMD)
147
+ duplicate_count = 0
143
148
  for group_key, group_df in grouped:
144
149
  # Convert group to list of dicts
145
150
  rows = group_df.to_dicts()
146
151
  # Handle None keys (can't join on None)
147
152
  if group_key is not None:
148
- self.lookup_index[group_key] = rows
153
+ # If first_match_only, only keep first row per key
154
+ if self.first_match_only and len(rows) > 1:
155
+ duplicate_count += len(rows) - 1
156
+ self.lookup_index[group_key] = rows[:1] # Only first match
157
+ else:
158
+ self.lookup_index[group_key] = rows
149
159
 
150
160
  if self.debug:
151
161
  unique_keys = len(self.lookup_index)
152
162
  print(f" Polars index built (SIMD): {row_count:,} rows, {unique_keys:,} unique keys")
163
+ if self.first_match_only and duplicate_count > 0:
164
+ print(f" ⚠️ Deduplicated: {duplicate_count:,} duplicate keys removed (kept first match only)")
153
165
 
154
166
  except Exception as e:
155
167
  if self.debug:
@@ -162,6 +174,7 @@ class PolarsLookupJoinIterator:
162
174
  """Fallback: Build Python dict index (original implementation)."""
163
175
  self.lookup_index = {}
164
176
  index_size = 0
177
+ duplicate_count = 0
165
178
 
166
179
  for prefixed_row in right_rows:
167
180
  key_value = prefixed_row.get(f"{self.right_alias}.{self.right_table_col}")
@@ -171,11 +184,22 @@ class PolarsLookupJoinIterator:
171
184
  if key_value is not None:
172
185
  if key_value not in self.lookup_index:
173
186
  self.lookup_index[key_value] = []
174
- self.lookup_index[key_value].append(prefixed_row)
175
- index_size += 1
187
+ self.lookup_index[key_value].append(prefixed_row)
188
+ index_size += 1
189
+ else:
190
+ # Key already exists
191
+ if self.first_match_only:
192
+ # Skip duplicates - only keep first match
193
+ duplicate_count += 1
194
+ else:
195
+ # Keep all matches (normal SQL behavior)
196
+ self.lookup_index[key_value].append(prefixed_row)
197
+ index_size += 1
176
198
 
177
199
  if self.debug:
178
200
  print(f" Python index built: {index_size:,} rows, {len(self.lookup_index):,} unique keys")
201
+ if self.first_match_only and duplicate_count > 0:
202
+ print(f" ⚠️ Deduplicated: {duplicate_count:,} duplicate keys removed (kept first match only)")
179
203
 
180
204
  def __iter__(self):
181
205
  return self
@@ -222,6 +246,10 @@ class PolarsLookupJoinIterator:
222
246
  # Filter out None or invalid rows
223
247
  self._right_matches = [m for m in matches
224
248
  if m is not None and isinstance(m, dict)]
249
+
250
+ # If first_match_only mode, only take first match
251
+ if self.first_match_only and len(self._right_matches) > 1:
252
+ self._right_matches = self._right_matches[:1]
225
253
 
226
254
  # Handle INNER JOIN
227
255
  if self.join_type == "INNER":
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "streaming-sql-engine"
7
- version = "0.1.12"
7
+ version = "0.1.13"
8
8
  description = "A lightweight SQL execution engine for streaming row-by-row queries with joins across multiple data sources"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -12,7 +12,7 @@ with open("requirements.txt", "r", encoding="utf-8") as fh:
12
12
 
13
13
  setup(
14
14
  name="streaming-sql-engine",
15
- version="0.1.12",
15
+ version="0.1.13",
16
16
  author="Theodore Pantazopoulo",
17
17
  author_email="your.email@example.com",
18
18
  description="A lightweight SQL execution engine for streaming row-by-row queries with joins across multiple data sources",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streaming-sql-engine
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: A lightweight SQL execution engine for streaming row-by-row queries with joins across multiple data sources
5
5
  Home-page: https://github.com/Ierofantis/streaming-sql-engine/tree/master
6
6
  Author: Theodore Pantazopoulo