streaming-sql-engine 0.1.27__tar.gz → 0.1.28__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.
- {streaming_sql_engine-0.1.27/streaming_sql_engine.egg-info → streaming_sql_engine-0.1.28}/PKG-INFO +1 -1
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/__init__.py +1 -1
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/benchmark_all_configurations.py +208 -3
- streaming_sql_engine-0.1.28/debug_where.py +48 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/evaluator.py +14 -1
- streaming_sql_engine-0.1.28/executor.py +558 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/operators.py +55 -7
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/operators_polars.py +53 -22
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/polars_expression_translator.py +21 -3
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/pyproject.toml +1 -1
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/setup.py +1 -1
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28/streaming_sql_engine.egg-info}/PKG-INFO +1 -1
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/streaming_sql_engine.egg-info/SOURCES.txt +14 -0
- streaming_sql_engine-0.1.28/test_evaluator_direct.py +64 -0
- streaming_sql_engine-0.1.28/test_lookup_join_where.py +225 -0
- streaming_sql_engine-0.1.28/test_polars_where.py +86 -0
- streaming_sql_engine-0.1.28/test_where_debug_simple.py +87 -0
- streaming_sql_engine-0.1.28/test_where_fix.py +67 -0
- streaming_sql_engine-0.1.28/test_where_string.py +107 -0
- streaming_sql_engine-0.1.27/planner.py +0 -252
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/DEPLOYMENT.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/MANIFEST.in +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/QUICK_DEPLOY.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/QUICK_FIX.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/README.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/benchmark_all_configurations_1k.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/APACHE_DRILL_COMPARISON.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/API_JOIN_OPERATIONS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/ARCHITECTURAL_RECOMMENDATION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/ARCHITECTURE_DECISION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/ARCHITECTURE_SYNCED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/BEST_USE_CASES.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/BETTER_FILTER_APPROACH.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/CARTESIAN_PRODUCTS_CAUSES.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/CHANGES_SUMMARY.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/COMPREHENSIVE_ARTICLE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/COMPREHENSIVE_DOCUMENTATION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/COMPREHENSIVE_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/DEVELOPER_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/DUCKDB_COMPARISON.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/ENGINE_OPTIONS_REFERENCE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/FINAL_IMPLEMENTATION_RECOMMENDATIONS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/FINAL_RECOMMENDATION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/FIRST_MATCH_ONLY_WARNINGS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/HANDLING_DUPLICATES_WITHOUT_CARTESIAN.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/HOW_PROTOCOL_DETECTION_WORKS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/HOW_TO_ADD_TO_PROJECT.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/INSTALLATION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/JSONL_EXECUTOR_ANALYSIS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/JSONL_EXECUTOR_REMOVED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/LIBRARY_DOCUMENTATION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/MEDIUM_ARTICLE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/MEDIUM_ARTICLE_SIMPLIFIED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/MIGRATION_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/MMAP_WITHOUT_POLARS_SLOW.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/MOST_STABLE_AND_PERFORMANT.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/MULTI_SOURCE_EXAMPLE_README.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/MYSQL_USAGE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/OPTIMIZATIONS_BREAKDOWN.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/OPTIMIZATIONS_NOT_DATABASE_ONLY.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/OPTIMIZATIONS_VS_POLARS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/OPTIMIZER_AUTOMATED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/PERFORMANCE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/PERFORMANCE_COMPARISON.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/POLARS_AND_MMAP_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/POLARS_VS_POLARS_MMAP.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/PROTOCOL_AND_OPTIMIZATIONS_EXPLAINED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/PROTOCOL_EXPLANATION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/PUBLISHING.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/PYPI_CHECKLIST.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/QUICK_PUBLISH.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/QUICK_START.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/SIMPLE_PROTOCOL_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/SIMPLE_SOURCE_FUNCTIONS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/SOURCE_COMBINATIONS_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/TECHNICAL_DOCUMENTATION.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/USER_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/WHAT_IS_WHERE_TO_PARAMS.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/WHEN_POLARS_IS_USED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/WHERE_POLARS_IS_USED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/WHY_API_CONVERTER_NEEDED.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/WHY_MANUAL_PARSING.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/WHY_ORIGINAL_IS_FASTER.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/WHY_PROTOCOL_IN_SOURCES.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/documentation/XML_MONGO_USE_CASE.md +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/engine.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/mmap_index.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/operators_mmap.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/optimized_export.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/optimizer.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/parser.py +0 -0
- /streaming_sql_engine-0.1.27/executor.py → /streaming_sql_engine-0.1.28/planner.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/polars_operators.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/pre_release_test.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/protocol_helpers.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/quick_test.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/requirements.txt +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/setup.cfg +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/streaming_sql_engine.egg-info/dependency_links.txt +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/streaming_sql_engine.egg-info/requires.txt +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/streaming_sql_engine.egg-info/top_level.txt +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_engine_options.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_full_pipeline.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_merge_buffer.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_merge_join_debug.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_merge_join_detailed_debug.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_merge_join_direct.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_merge_join_issue.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_merge_join_simple.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_merge_join_with_user_data.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_debug.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_direct.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_get_matches.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_get_matches_direct.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_get_rows_variants.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_index.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_index_lookup.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_join_benchmark_match.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_join_debug.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_join_simple.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_join_simple_fixed.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_join_trace.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_key_extraction.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_required_columns.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_mmap_simple_query.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_polars_fixes.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_polars_schema_fix.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_readme_cases.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_required_columns_analysis.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_where_clause_1k.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_where_debug.py +0 -0
- {streaming_sql_engine-0.1.27 → streaming_sql_engine-0.1.28}/tests/test_where_pushdown.py +0 -0
{streaming_sql_engine-0.1.27/streaming_sql_engine.egg-info → streaming_sql_engine-0.1.28}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: streaming-sql-engine
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.28
|
|
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
|
|
@@ -70,6 +70,140 @@ def get_cpu_percent():
|
|
|
70
70
|
return psutil.cpu_percent(interval=0.1)
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
def analyze_results(output_file, expected_products_checked_1):
|
|
74
|
+
"""Analyze results for inconsistencies."""
|
|
75
|
+
issues = []
|
|
76
|
+
|
|
77
|
+
if not os.path.exists(output_file):
|
|
78
|
+
return {
|
|
79
|
+
"total_rows": 0,
|
|
80
|
+
"unique_products": 0,
|
|
81
|
+
"products_with_images": 0,
|
|
82
|
+
"products_without_images": 0,
|
|
83
|
+
"issues": [f"Output file not found: {output_file}"]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
rows = []
|
|
87
|
+
with open(output_file, "r", encoding="utf-8") as f:
|
|
88
|
+
for line in f:
|
|
89
|
+
if line.strip():
|
|
90
|
+
rows.append(json.loads(line))
|
|
91
|
+
|
|
92
|
+
total_rows = len(rows)
|
|
93
|
+
|
|
94
|
+
# Check row count consistency
|
|
95
|
+
if total_rows == 0:
|
|
96
|
+
issues.append("[ERROR] No rows returned")
|
|
97
|
+
|
|
98
|
+
# Check for missing images (should have images for products with checked=1)
|
|
99
|
+
products_with_images = set()
|
|
100
|
+
products_without_images = set()
|
|
101
|
+
|
|
102
|
+
for row in rows:
|
|
103
|
+
product_id = row.get("product_id")
|
|
104
|
+
image = row.get("image")
|
|
105
|
+
|
|
106
|
+
if image is None:
|
|
107
|
+
products_without_images.add(product_id)
|
|
108
|
+
else:
|
|
109
|
+
products_with_images.add(product_id)
|
|
110
|
+
|
|
111
|
+
# Check for duplicate product_ids (should have multiple rows per product if multiple images)
|
|
112
|
+
product_counts = {}
|
|
113
|
+
for row in rows:
|
|
114
|
+
pid = row.get("product_id")
|
|
115
|
+
product_counts[pid] = product_counts.get(pid, 0) + 1
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
"total_rows": total_rows,
|
|
119
|
+
"unique_products": len(product_counts),
|
|
120
|
+
"products_with_images": len(products_with_images),
|
|
121
|
+
"products_without_images": len(products_without_images),
|
|
122
|
+
"issues": issues
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def compare_results(all_results):
|
|
127
|
+
"""Compare results across all configurations to ensure consistency."""
|
|
128
|
+
valid_results = [r for r in all_results if "error" not in r and r.get("rows", 0) > 0]
|
|
129
|
+
|
|
130
|
+
if len(valid_results) < 2:
|
|
131
|
+
return {"consistent": True, "issues": []}
|
|
132
|
+
|
|
133
|
+
# Get row counts
|
|
134
|
+
row_counts = [r["rows"] for r in valid_results]
|
|
135
|
+
unique_products = [r.get("analysis", {}).get("unique_products", 0) for r in valid_results]
|
|
136
|
+
|
|
137
|
+
issues = []
|
|
138
|
+
|
|
139
|
+
# Group configurations by expected behavior
|
|
140
|
+
# IMPORTANT: "Filter pushdown" and "column pruning" are performance optimizations.
|
|
141
|
+
# They should NOT change the final output row count for the same SQL query.
|
|
142
|
+
#
|
|
143
|
+
# Configs 1-4: No pushdown/pruning protocol (WHERE applied after join in engine)
|
|
144
|
+
# Configs 5-6: Pushdown/pruning protocol enabled (WHERE can be applied while scanning)
|
|
145
|
+
# Config 7: first_match_only changes semantics (may reduce duplicate joined rows)
|
|
146
|
+
|
|
147
|
+
baseline_configs = [r for r in valid_results if "Merge Join" in r['name'] or "Lookup Join" in r['name'] or "Polars Join" in r['name'] or "MMAP Join" in r['name']]
|
|
148
|
+
optimized_configs = [r for r in valid_results if "Column Pruning" in r['name'] or "Filter Pushdown" in r['name']]
|
|
149
|
+
first_match_configs = [r for r in valid_results if "All Optimizations" in r['name']]
|
|
150
|
+
|
|
151
|
+
# Check consistency within baseline configs (should all return same)
|
|
152
|
+
if len(baseline_configs) > 1:
|
|
153
|
+
baseline_row_counts = [r["rows"] for r in baseline_configs]
|
|
154
|
+
if len(set(baseline_row_counts)) > 1:
|
|
155
|
+
issues.append(f"[WARNING] Baseline configs row count mismatch: {dict(zip([r['name'] for r in baseline_configs], baseline_row_counts))}")
|
|
156
|
+
|
|
157
|
+
# Check consistency within optimized configs (should all return same)
|
|
158
|
+
if len(optimized_configs) > 1:
|
|
159
|
+
optimized_row_counts = [r["rows"] for r in optimized_configs]
|
|
160
|
+
if len(set(optimized_row_counts)) > 1:
|
|
161
|
+
issues.append(f"[WARNING] Optimized configs row count mismatch: {dict(zip([r['name'] for r in optimized_configs], optimized_row_counts))}")
|
|
162
|
+
|
|
163
|
+
# Check that first_match configs return fewer rows than optimized (due to first_match_only)
|
|
164
|
+
if optimized_configs and first_match_configs:
|
|
165
|
+
optimized_avg = sum(r["rows"] for r in optimized_configs) / len(optimized_configs)
|
|
166
|
+
first_match_avg = sum(r["rows"] for r in first_match_configs) / len(first_match_configs)
|
|
167
|
+
if first_match_avg >= optimized_avg:
|
|
168
|
+
issues.append(f"[WARNING] First match configs should return fewer rows, but got {first_match_avg:.0f} vs optimized {optimized_avg:.0f}")
|
|
169
|
+
|
|
170
|
+
# Compare actual data content (sample first 100 rows from each)
|
|
171
|
+
if len(valid_results) > 1:
|
|
172
|
+
sample_data = {}
|
|
173
|
+
for result in valid_results:
|
|
174
|
+
if result.get("output_file") and os.path.exists(result["output_file"]):
|
|
175
|
+
samples = []
|
|
176
|
+
with open(result["output_file"], "r", encoding="utf-8") as f:
|
|
177
|
+
for i, line in enumerate(f):
|
|
178
|
+
if i >= 100:
|
|
179
|
+
break
|
|
180
|
+
if line.strip():
|
|
181
|
+
samples.append(json.loads(line))
|
|
182
|
+
sample_data[result["name"]] = samples
|
|
183
|
+
|
|
184
|
+
# Compare samples
|
|
185
|
+
if len(sample_data) > 1:
|
|
186
|
+
first_config = list(sample_data.keys())[0]
|
|
187
|
+
first_samples = sample_data[first_config]
|
|
188
|
+
|
|
189
|
+
for config_name, samples in list(sample_data.items())[1:]:
|
|
190
|
+
if len(samples) != len(first_samples):
|
|
191
|
+
issues.append(f"[WARNING] Sample size mismatch: {first_config} has {len(first_samples)} rows, {config_name} has {len(samples)} rows")
|
|
192
|
+
else:
|
|
193
|
+
# Compare product_ids
|
|
194
|
+
first_pids = sorted([r.get("product_id") for r in first_samples])
|
|
195
|
+
other_pids = sorted([r.get("product_id") for r in samples])
|
|
196
|
+
if first_pids != other_pids:
|
|
197
|
+
issues.append(f"[WARNING] Product ID mismatch between {first_config} and {config_name}")
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
"consistent": len(issues) == 0,
|
|
201
|
+
"issues": issues,
|
|
202
|
+
"row_counts": dict(zip([r['name'] for r in valid_results], row_counts)),
|
|
203
|
+
"unique_products": dict(zip([r['name'] for r in valid_results], unique_products))
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
73
207
|
def run_benchmark(name, engine_config, source_config, query, products_file, images_file):
|
|
74
208
|
"""
|
|
75
209
|
Run a benchmark with specific configuration.
|
|
@@ -153,9 +287,15 @@ def run_benchmark(name, engine_config, source_config, query, products_file, imag
|
|
|
153
287
|
f.write(json.dumps(row, ensure_ascii=False) + "\n")
|
|
154
288
|
export_time = time.time() - export_start
|
|
155
289
|
|
|
156
|
-
import os
|
|
157
290
|
file_size_mb = os.path.getsize(output_file) / (1024 * 1024)
|
|
158
291
|
|
|
292
|
+
# Analyze results (calculate expected_products_checked_1 from products_file)
|
|
293
|
+
expected_products_checked_1 = sum(
|
|
294
|
+
1 for line in open(products_file)
|
|
295
|
+
if line.strip() and json.loads(line).get("checked") == 1
|
|
296
|
+
)
|
|
297
|
+
analysis = analyze_results(output_file, expected_products_checked_1)
|
|
298
|
+
|
|
159
299
|
results = {
|
|
160
300
|
"name": name,
|
|
161
301
|
"rows": row_count,
|
|
@@ -166,11 +306,15 @@ def run_benchmark(name, engine_config, source_config, query, products_file, imag
|
|
|
166
306
|
"avg_cpu_percent": avg_cpu,
|
|
167
307
|
"rows_per_second": row_count / elapsed_time if elapsed_time > 0 else 0,
|
|
168
308
|
"output_file": output_file,
|
|
169
|
-
"output_file_size_mb": file_size_mb
|
|
309
|
+
"output_file_size_mb": file_size_mb,
|
|
310
|
+
"analysis": analysis
|
|
170
311
|
}
|
|
171
312
|
|
|
172
313
|
print(f" Results:")
|
|
173
314
|
print(f" Rows processed: {row_count:,}")
|
|
315
|
+
print(f" Unique products: {analysis['unique_products']}")
|
|
316
|
+
print(f" Products with images: {analysis['products_with_images']}")
|
|
317
|
+
print(f" Products without images: {analysis['products_without_images']}")
|
|
174
318
|
print(f" Time: {elapsed_time:.2f} seconds")
|
|
175
319
|
print(f" Speed: {results['rows_per_second']:,.0f} rows/second")
|
|
176
320
|
print(f" Peak memory: {peak_memory:.2f} MB")
|
|
@@ -178,6 +322,11 @@ def run_benchmark(name, engine_config, source_config, query, products_file, imag
|
|
|
178
322
|
print(f" Avg CPU: {avg_cpu:.1f}%")
|
|
179
323
|
print(f" Exported to: {output_file} ({file_size_mb:.2f} MB)")
|
|
180
324
|
|
|
325
|
+
if analysis['issues']:
|
|
326
|
+
print(f" [WARNING] Issues found:")
|
|
327
|
+
for issue in analysis['issues']:
|
|
328
|
+
print(f" {issue}")
|
|
329
|
+
|
|
181
330
|
return results
|
|
182
331
|
|
|
183
332
|
except Exception as e:
|
|
@@ -194,7 +343,8 @@ def run_benchmark(name, engine_config, source_config, query, products_file, imag
|
|
|
194
343
|
"avg_cpu_percent": 0,
|
|
195
344
|
"rows_per_second": 0,
|
|
196
345
|
"output_file": None,
|
|
197
|
-
"output_file_size_mb": 0
|
|
346
|
+
"output_file_size_mb": 0,
|
|
347
|
+
"analysis": {"issues": [f"Error: {str(e)}"]}
|
|
198
348
|
}
|
|
199
349
|
|
|
200
350
|
|
|
@@ -213,6 +363,28 @@ def main():
|
|
|
213
363
|
print("Run: python generate_test_data_100k.py")
|
|
214
364
|
return
|
|
215
365
|
|
|
366
|
+
# Calculate expected values
|
|
367
|
+
products_checked_1 = sum(
|
|
368
|
+
1 for line in open(products_file)
|
|
369
|
+
if line.strip() and json.loads(line).get("checked") == 1
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
# Build images index
|
|
373
|
+
images_by_product = {}
|
|
374
|
+
for line in open(images_file):
|
|
375
|
+
if line.strip():
|
|
376
|
+
img = json.loads(line)
|
|
377
|
+
pid = img.get("product_id")
|
|
378
|
+
if pid not in images_by_product:
|
|
379
|
+
images_by_product[pid] = []
|
|
380
|
+
images_by_product[pid].append(img)
|
|
381
|
+
|
|
382
|
+
expected_rows = sum(
|
|
383
|
+
len(images_by_product.get(json.loads(line).get("product_id"), []))
|
|
384
|
+
for line in open(products_file)
|
|
385
|
+
if line.strip() and json.loads(line).get("checked") == 1
|
|
386
|
+
)
|
|
387
|
+
|
|
216
388
|
# Query to test
|
|
217
389
|
query = """
|
|
218
390
|
SELECT
|
|
@@ -234,6 +406,10 @@ def main():
|
|
|
234
406
|
print(f" Products: {products_file}")
|
|
235
407
|
print(f" Images: {images_file}")
|
|
236
408
|
print()
|
|
409
|
+
print(f"Expected:")
|
|
410
|
+
print(f" Products with checked=1: {products_checked_1}")
|
|
411
|
+
print(f" Expected joined rows: ~{expected_rows}")
|
|
412
|
+
print()
|
|
237
413
|
print(f"Query:")
|
|
238
414
|
print(query)
|
|
239
415
|
print()
|
|
@@ -386,6 +562,35 @@ def main():
|
|
|
386
562
|
f"{result['memory_overhead_mb']:>12.2f} {result['avg_cpu_percent']:>8.1f} "
|
|
387
563
|
f"{result['rows_per_second']:>12,.0f} {output_info:<30}")
|
|
388
564
|
|
|
565
|
+
print()
|
|
566
|
+
print("=" * 70)
|
|
567
|
+
print("RESULT VALIDATION")
|
|
568
|
+
print("=" * 70)
|
|
569
|
+
print()
|
|
570
|
+
|
|
571
|
+
# Compare results across configurations
|
|
572
|
+
comparison = compare_results(all_results)
|
|
573
|
+
|
|
574
|
+
if comparison["consistent"]:
|
|
575
|
+
print("[OK] All configurations returned consistent results!")
|
|
576
|
+
print(f" Row counts: {comparison['row_counts']}")
|
|
577
|
+
print(f" Unique products: {comparison['unique_products']}")
|
|
578
|
+
else:
|
|
579
|
+
print("[WARNING] Some inconsistencies found between configurations:")
|
|
580
|
+
for issue in comparison["issues"]:
|
|
581
|
+
print(f" {issue}")
|
|
582
|
+
print()
|
|
583
|
+
print(" Row counts by configuration:")
|
|
584
|
+
for name, count in comparison['row_counts'].items():
|
|
585
|
+
print(f" {name}: {count:,}")
|
|
586
|
+
|
|
587
|
+
# Explain expected differences
|
|
588
|
+
print()
|
|
589
|
+
print(" Expected differences:")
|
|
590
|
+
print(" - Configs 1-4: No filter pushdown to source; WHERE is evaluated in-engine after join")
|
|
591
|
+
print(" - Configs 5-6: Filter pushdown/column pruning enabled; WHERE may be applied while scanning (same final rows, less work)")
|
|
592
|
+
print(" - Config 7: first_match_only enabled; may return fewer rows (1 match per product)")
|
|
593
|
+
|
|
389
594
|
print()
|
|
390
595
|
print("=" * 70)
|
|
391
596
|
print("RECOMMENDATIONS")
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Debug WHERE clause issue"""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from streaming_sql_engine import Engine
|
|
5
|
+
|
|
6
|
+
def load_jsonl_file(filename):
|
|
7
|
+
"""Simple JSONL loader without protocol support."""
|
|
8
|
+
with open(filename, "r", encoding="utf-8") as f:
|
|
9
|
+
for line in f:
|
|
10
|
+
if line.strip():
|
|
11
|
+
row = json.loads(line)
|
|
12
|
+
print(f"Source row columns: {list(row.keys())}")
|
|
13
|
+
print(f"Has 'checked': {'checked' in row}")
|
|
14
|
+
yield row
|
|
15
|
+
break # Just first row for debugging
|
|
16
|
+
|
|
17
|
+
# Initialize engine
|
|
18
|
+
engine = Engine(debug=True, use_polars=False, first_match_only=False)
|
|
19
|
+
|
|
20
|
+
# Register sources (without protocol support)
|
|
21
|
+
engine.register("products", lambda: load_jsonl_file("products_3_1k.jsonl"))
|
|
22
|
+
engine.register("images", lambda: load_jsonl_file("images_3_1k.jsonl"))
|
|
23
|
+
|
|
24
|
+
# Query with WHERE clause
|
|
25
|
+
query = """
|
|
26
|
+
SELECT
|
|
27
|
+
products.product_id,
|
|
28
|
+
products.product_sku,
|
|
29
|
+
products.title,
|
|
30
|
+
images.image,
|
|
31
|
+
images.image_type
|
|
32
|
+
FROM products
|
|
33
|
+
LEFT JOIN images ON products.product_id = images.product_id
|
|
34
|
+
WHERE products.checked = 1
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
print("Executing query...")
|
|
38
|
+
print()
|
|
39
|
+
|
|
40
|
+
row_count = 0
|
|
41
|
+
for row in engine.query(query):
|
|
42
|
+
row_count += 1
|
|
43
|
+
print(f"Result row {row_count} columns: {list(row.keys())}")
|
|
44
|
+
print(f"Has 'checked': {'checked' in row or 'products.checked' in row}")
|
|
45
|
+
if row_count >= 3:
|
|
46
|
+
break
|
|
47
|
+
|
|
48
|
+
print(f"\nTotal rows returned: {row_count}")
|
|
@@ -103,7 +103,20 @@ def evaluate_expression(expr, row):
|
|
|
103
103
|
|
|
104
104
|
elif expr_type is _LITERAL_TYPE:
|
|
105
105
|
# Literal value
|
|
106
|
-
|
|
106
|
+
value = expr.this
|
|
107
|
+
# sqlglot stores numeric literals as strings, so convert them back to numbers
|
|
108
|
+
if isinstance(value, str):
|
|
109
|
+
# Try to convert string to number if it looks like a number
|
|
110
|
+
try:
|
|
111
|
+
# Check if it's a float (has decimal point or scientific notation)
|
|
112
|
+
if '.' in value or 'e' in value.lower() or 'E' in value:
|
|
113
|
+
return float(value)
|
|
114
|
+
# Otherwise try integer
|
|
115
|
+
return int(value)
|
|
116
|
+
except (ValueError, TypeError):
|
|
117
|
+
# Not a number, return as string
|
|
118
|
+
pass
|
|
119
|
+
return value
|
|
107
120
|
|
|
108
121
|
elif expr_type is _EQ_TYPE:
|
|
109
122
|
# Equality: left = right
|