streaming-sql-engine 0.1.18__tar.gz → 0.1.20__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 (85) hide show
  1. {streaming_sql_engine-0.1.18/streaming_sql_engine.egg-info → streaming_sql_engine-0.1.20}/PKG-INFO +1 -1
  2. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/__init__.py +4 -4
  3. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/pyproject.toml +66 -66
  4. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/setup.py +1 -1
  5. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20/streaming_sql_engine.egg-info}/PKG-INFO +1 -1
  6. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/streaming_sql_engine.egg-info/SOURCES.txt +4 -0
  7. streaming_sql_engine-0.1.20/test_polars_fixes.py +186 -0
  8. streaming_sql_engine-0.1.20/test_polars_schema_fix.py +147 -0
  9. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/DEPLOYMENT.md +0 -0
  10. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/MANIFEST.in +0 -0
  11. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/QUICK_DEPLOY.md +0 -0
  12. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/QUICK_FIX.md +0 -0
  13. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/README.md +0 -0
  14. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/APACHE_DRILL_COMPARISON.md +0 -0
  15. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/API_JOIN_OPERATIONS.md +0 -0
  16. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/ARCHITECTURAL_RECOMMENDATION.md +0 -0
  17. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/ARCHITECTURE_DECISION.md +0 -0
  18. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/ARCHITECTURE_SYNCED.md +0 -0
  19. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/BEST_USE_CASES.md +0 -0
  20. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/BETTER_FILTER_APPROACH.md +0 -0
  21. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/CARTESIAN_PRODUCTS_CAUSES.md +0 -0
  22. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/CHANGES_SUMMARY.md +0 -0
  23. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/COMPREHENSIVE_ARTICLE.md +0 -0
  24. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/COMPREHENSIVE_DOCUMENTATION.md +0 -0
  25. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/DEVELOPER_GUIDE.md +0 -0
  26. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/DUCKDB_COMPARISON.md +0 -0
  27. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/ENGINE_OPTIONS_REFERENCE.md +0 -0
  28. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/FINAL_IMPLEMENTATION_RECOMMENDATIONS.md +0 -0
  29. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/FINAL_RECOMMENDATION.md +0 -0
  30. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/FIRST_MATCH_ONLY_WARNINGS.md +0 -0
  31. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/HANDLING_DUPLICATES_WITHOUT_CARTESIAN.md +0 -0
  32. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/HOW_PROTOCOL_DETECTION_WORKS.md +0 -0
  33. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/HOW_TO_ADD_TO_PROJECT.md +0 -0
  34. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/INSTALLATION.md +0 -0
  35. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/JSONL_EXECUTOR_ANALYSIS.md +0 -0
  36. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/JSONL_EXECUTOR_REMOVED.md +0 -0
  37. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/LIBRARY_DOCUMENTATION.md +0 -0
  38. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/MEDIUM_ARTICLE.md +0 -0
  39. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/MIGRATION_GUIDE.md +0 -0
  40. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/MULTI_SOURCE_EXAMPLE_README.md +0 -0
  41. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/MYSQL_USAGE.md +0 -0
  42. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/OPTIMIZATIONS_BREAKDOWN.md +0 -0
  43. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/OPTIMIZATIONS_NOT_DATABASE_ONLY.md +0 -0
  44. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/OPTIMIZATIONS_VS_POLARS.md +0 -0
  45. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/OPTIMIZER_AUTOMATED.md +0 -0
  46. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/PERFORMANCE.md +0 -0
  47. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/PERFORMANCE_COMPARISON.md +0 -0
  48. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/POLARS_AND_MMAP_GUIDE.md +0 -0
  49. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/PROTOCOL_AND_OPTIMIZATIONS_EXPLAINED.md +0 -0
  50. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/PROTOCOL_EXPLANATION.md +0 -0
  51. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/PUBLISHING.md +0 -0
  52. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/PYPI_CHECKLIST.md +0 -0
  53. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/QUICK_PUBLISH.md +0 -0
  54. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/QUICK_START.md +0 -0
  55. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/SIMPLE_PROTOCOL_GUIDE.md +0 -0
  56. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/SIMPLE_SOURCE_FUNCTIONS.md +0 -0
  57. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/SOURCE_COMBINATIONS_GUIDE.md +0 -0
  58. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/TECHNICAL_DOCUMENTATION.md +0 -0
  59. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/USER_GUIDE.md +0 -0
  60. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/WHAT_IS_WHERE_TO_PARAMS.md +0 -0
  61. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/WHEN_POLARS_IS_USED.md +0 -0
  62. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/WHERE_POLARS_IS_USED.md +0 -0
  63. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/WHY_API_CONVERTER_NEEDED.md +0 -0
  64. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/WHY_MANUAL_PARSING.md +0 -0
  65. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/WHY_ORIGINAL_IS_FASTER.md +0 -0
  66. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/WHY_PROTOCOL_IN_SOURCES.md +0 -0
  67. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/documentation/XML_MONGO_USE_CASE.md +0 -0
  68. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/engine.py +0 -0
  69. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/evaluator.py +0 -0
  70. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/executor.py +0 -0
  71. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/mmap_index.py +0 -0
  72. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/operators.py +0 -0
  73. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/operators_mmap.py +0 -0
  74. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/operators_polars.py +0 -0
  75. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/optimizer.py +0 -0
  76. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/parser.py +0 -0
  77. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/planner.py +0 -0
  78. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/polars_expression_translator.py +0 -0
  79. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/polars_operators.py +0 -0
  80. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/protocol_helpers.py +0 -0
  81. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/requirements.txt +0 -0
  82. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/setup.cfg +0 -0
  83. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/streaming_sql_engine.egg-info/dependency_links.txt +0 -0
  84. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/streaming_sql_engine.egg-info/requires.txt +0 -0
  85. {streaming_sql_engine-0.1.18 → streaming_sql_engine-0.1.20}/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.18
3
+ Version: 0.1.20
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
@@ -16,16 +16,16 @@ try:
16
16
  register_file_source,
17
17
  register_api_source,
18
18
  )
19
- __all__ = [
20
- "Engine",
19
+ __all__ = [
20
+ "Engine",
21
21
  "add_protocol_support",
22
22
  "wrap_simple_source",
23
23
  "create_protocol_source",
24
24
  "register_file_source",
25
25
  "register_api_source",
26
- ]
26
+ ]
27
27
  except ImportError:
28
28
  __all__ = ["Engine"]
29
29
 
30
- __version__ = "0.1.18"
30
+ __version__ = "0.1.19"
31
31
 
@@ -1,66 +1,66 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "streaming-sql-engine"
7
- version = "0.1.18"
8
- description = "A lightweight SQL execution engine for streaming row-by-row queries with joins across multiple data sources"
9
- readme = "README.md"
10
- requires-python = ">=3.8"
11
- authors = [
12
- {name = "Theodore Pantazopoulo", email = "your.email@example.com"}
13
- ]
14
- keywords = ["sql", "streaming", "join", "database", "query", "engine", "etl", "data-integration"]
15
- classifiers = [
16
- "Development Status :: 3 - Alpha",
17
- "Intended Audience :: Developers",
18
- "Topic :: Software Development :: Libraries :: Python Modules",
19
- "Topic :: Database",
20
- "License :: OSI Approved :: MIT License",
21
- "Programming Language :: Python :: 3",
22
- "Programming Language :: Python :: 3.8",
23
- "Programming Language :: Python :: 3.9",
24
- "Programming Language :: Python :: 3.10",
25
- "Programming Language :: Python :: 3.11",
26
- "Programming Language :: Python :: 3.12",
27
- ]
28
- dependencies = [
29
- "sqlglot>=23.0.0",
30
- "polars>=0.19.0", # Required for default use_polars=True optimization
31
- ]
32
-
33
- [project.optional-dependencies]
34
- # Polars is now a required dependency (moved to dependencies above)
35
- db = [
36
- "psycopg2-binary>=2.9.0",
37
- "pymysql>=1.0.0",
38
- "DBUtils>=3.0.0",
39
- "pymongo>=4.0.0",
40
- ]
41
- dev = [
42
- "pytest>=7.0.0",
43
- "pytest-cov>=4.0.0",
44
- "black>=23.0.0",
45
- "flake8>=6.0.0",
46
- ]
47
- all = [
48
- "psycopg2-binary>=2.9.0",
49
- "pymysql>=1.0.0",
50
- "DBUtils>=3.0.0",
51
- "pymongo>=4.0.0",
52
- ]
53
-
54
- [project.urls]
55
- Homepage = "https://github.com/Ierofantis/streaming-sql-engine/tree/master"
56
- Repository = "https://github.com/Ierofantis/streaming-sql-engine/tree/master"
57
- Issues = "https://github.com/Ierofantis/streaming-sql-engine/issues"
58
- Documentation = "https://github.com/Ierofantis/streaming-sql-engine/tree/master#readme"
59
-
60
- [tool.setuptools]
61
- packages = ["streaming_sql_engine"]
62
- package-dir = {"streaming_sql_engine" = "."}
63
-
64
- [tool.setuptools.package-data]
65
- "*" = ["*.md", "*.txt"]
66
-
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "streaming-sql-engine"
7
+ version = "0.1.20"
8
+ description = "A lightweight SQL execution engine for streaming row-by-row queries with joins across multiple data sources"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ authors = [
12
+ {name = "Theodore Pantazopoulo", email = "your.email@example.com"}
13
+ ]
14
+ keywords = ["sql", "streaming", "join", "database", "query", "engine", "etl", "data-integration"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Topic :: Software Development :: Libraries :: Python Modules",
19
+ "Topic :: Database",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ ]
28
+ dependencies = [
29
+ "sqlglot>=23.0.0",
30
+ "polars>=0.19.0", # Required for default use_polars=True optimization
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ # Polars is now a required dependency (moved to dependencies above)
35
+ db = [
36
+ "psycopg2-binary>=2.9.0",
37
+ "pymysql>=1.0.0",
38
+ "DBUtils>=3.0.0",
39
+ "pymongo>=4.0.0",
40
+ ]
41
+ dev = [
42
+ "pytest>=7.0.0",
43
+ "pytest-cov>=4.0.0",
44
+ "black>=23.0.0",
45
+ "flake8>=6.0.0",
46
+ ]
47
+ all = [
48
+ "psycopg2-binary>=2.9.0",
49
+ "pymysql>=1.0.0",
50
+ "DBUtils>=3.0.0",
51
+ "pymongo>=4.0.0",
52
+ ]
53
+
54
+ [project.urls]
55
+ Homepage = "https://github.com/Ierofantis/streaming-sql-engine/tree/master"
56
+ Repository = "https://github.com/Ierofantis/streaming-sql-engine/tree/master"
57
+ Issues = "https://github.com/Ierofantis/streaming-sql-engine/issues"
58
+ Documentation = "https://github.com/Ierofantis/streaming-sql-engine/tree/master#readme"
59
+
60
+ [tool.setuptools]
61
+ packages = ["streaming_sql_engine"]
62
+ package-dir = {"streaming_sql_engine" = "."}
63
+
64
+ [tool.setuptools.package-data]
65
+ "*" = ["*.md", "*.txt"]
66
+
@@ -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.18",
15
+ version="0.1.20",
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.18
3
+ Version: 0.1.20
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
@@ -20,6 +20,8 @@ protocol_helpers.py
20
20
  pyproject.toml
21
21
  requirements.txt
22
22
  setup.py
23
+ test_polars_fixes.py
24
+ test_polars_schema_fix.py
23
25
  ./DEPLOYMENT.md
24
26
  ./QUICK_DEPLOY.md
25
27
  ./QUICK_FIX.md
@@ -40,6 +42,8 @@ setup.py
40
42
  ./protocol_helpers.py
41
43
  ./requirements.txt
42
44
  ./setup.py
45
+ ./test_polars_fixes.py
46
+ ./test_polars_schema_fix.py
43
47
  documentation/APACHE_DRILL_COMPARISON.md
44
48
  documentation/API_JOIN_OPERATIONS.md
45
49
  documentation/ARCHITECTURAL_RECOMMENDATION.md
@@ -0,0 +1,186 @@
1
+ """
2
+ Test script for Polars fixes with sample MongoDB and Spryker data.
3
+ Tests schema inference and duplicate column name handling.
4
+ """
5
+
6
+ import json
7
+ import tempfile
8
+ import os
9
+ from pathlib import Path
10
+ import sys
11
+
12
+ # Add parent directory to path
13
+ sys.path.insert(0, str(Path(__file__).parent))
14
+
15
+ from streaming_sql_engine import Engine
16
+
17
+ # Sample MongoDB data (with product_offer_reference to match Spryker)
18
+ mongo_data = [
19
+ {"sku": "96771", "price": "8.50", "list_price": None, "publish": False, "status": "D", "product_id": 34017149, "sf_sku": "SF-06349323", "merchant_reference": "MER304", "product_offer_reference": "MER304--.--96771--.--SF-06349323"},
20
+ {"sku": "96821", "price": "9.40", "list_price": None, "publish": False, "status": "D", "product_id": 34017404, "sf_sku": "SF-02477384", "merchant_reference": "MER304", "product_offer_reference": "MER304--.--96821--.--SF-02477384"},
21
+ {"sku": "8833", "price": "122.80", "list_price": "150.00", "publish": True, "status": "A", "product_id": 34018000, "sf_sku": "SF-14041047", "merchant_reference": "MER304", "product_offer_reference": "MER304--.--8833--.--SF-14041047"},
22
+ {"sku": "8848", "price": "99.50", "list_price": None, "publish": True, "status": "A", "product_id": 34018001, "sf_sku": "SF-14041057", "merchant_reference": "MER304", "product_offer_reference": "MER304--.--8848--.--SF-14041057"},
23
+ ]
24
+
25
+ # Sample Spryker data
26
+ spryker_data = [
27
+ {"id_product_offer": 152860217, "approval_status": "approved", "concrete_sku": "SF-14041047", "is_active": 1, "merchant_reference": "MER304", "merchant_sku": "8833", "product_offer_reference": "MER304--.--8833--.--SF-14041047", "sf_merchant_ean": "8021233128240", "sf_merchant_product_name": "Parlux Advance Light Gold 2200Watt", "sf_merchant_url": "https://hairbeautycorner.com/parlux-advance-light-gold-2200watt", "sf_shipping_lead_time": 0, "gross_price": "122.80", "reference": "MER304--.--8833--.--SF-14041047", "price_type": 1, "query": "reference"},
28
+ {"id_product_offer": 152860218, "approval_status": "approved", "concrete_sku": "SF-14041057", "is_active": 1, "merchant_reference": "MER304", "merchant_sku": "8848", "product_offer_reference": "MER304--.--8848--.--SF-14041057", "sf_merchant_ean": "8021233121012", "sf_merchant_product_name": "Parlux Superturbo High Power 2400W", "sf_merchant_url": "https://hairbeautycorner.com/parlux-superturbo-high-power", "sf_shipping_lead_time": 0, "gross_price": "99.50", "reference": "MER304--.--8848--.--SF-14041057", "price_type": 1, "query": "reference"},
29
+ {"id_product_offer": 152860219, "approval_status": "pending", "concrete_sku": "SF-06349323", "is_active": 0, "merchant_reference": "MER304", "merchant_sku": "96771", "product_offer_reference": "MER304--.--96771--.--SF-06349323", "sf_merchant_ean": "8021233129999", "sf_merchant_product_name": "Test Product 1", "sf_merchant_url": "https://example.com/product1", "sf_shipping_lead_time": 1, "gross_price": "8.50", "reference": "MER304--.--96771--.--SF-06349323", "price_type": 1, "query": "reference"},
30
+ ]
31
+
32
+ def create_jsonl_file(data, filename):
33
+ """Create a JSONL file with the given data."""
34
+ with open(filename, 'w', encoding='utf-8') as f:
35
+ for record in data:
36
+ f.write(json.dumps(record) + '\n')
37
+ print(f"[OK] Created {filename} with {len(data)} records")
38
+
39
+ def load_jsonl_generator(filename):
40
+ """Generator function to load JSONL file."""
41
+ with open(filename, 'r', encoding='utf-8') as f:
42
+ for line in f:
43
+ if line.strip():
44
+ yield json.loads(line)
45
+
46
+ def test_reconciliation_query():
47
+ """Test the reconciliation query with Polars enabled."""
48
+ print("=" * 70)
49
+ print("TESTING POLARS FIXES")
50
+ print("=" * 70)
51
+ print()
52
+
53
+ # Create temporary JSONL files
54
+ mongo_file = "test_mongo.jsonl"
55
+ spryker_file = "test_spryker.jsonl"
56
+
57
+ try:
58
+ create_jsonl_file(mongo_data, mongo_file)
59
+ create_jsonl_file(spryker_data, spryker_file)
60
+
61
+ # Initialize engine with Polars enabled (debug=False to avoid Unicode issues on Windows)
62
+ print("\n[1] Initializing engine with Polars enabled...")
63
+ engine = Engine(debug=False, use_polars=True)
64
+ print("[OK] Engine initialized")
65
+
66
+ # Register sources
67
+ print("\n[2] Registering data sources...")
68
+ engine.register("mongo", lambda: load_jsonl_generator(mongo_file), filename=mongo_file)
69
+ engine.register("spryker", lambda: load_jsonl_generator(spryker_file), filename=spryker_file)
70
+ print("[OK] Sources registered")
71
+
72
+ # Test query 1: Reference match (similar to reconciliation script)
73
+ print("\n[3] Testing reference match query...")
74
+ print("-" * 70)
75
+ query1 = """
76
+ SELECT
77
+ spryker.id_product_offer,
78
+ spryker.approval_status,
79
+ spryker.concrete_sku,
80
+ spryker.is_active,
81
+ spryker.merchant_reference,
82
+ spryker.merchant_sku,
83
+ spryker.product_offer_reference,
84
+ spryker.sf_merchant_ean,
85
+ spryker.sf_merchant_product_name,
86
+ spryker.sf_merchant_url,
87
+ spryker.sf_shipping_lead_time,
88
+ mongo.price,
89
+ mongo.list_price,
90
+ spryker.query AS query_type,
91
+ mongo.price AS mongo_price,
92
+ spryker.gross_price AS spryker_price,
93
+ mongo.status AS mongo_status,
94
+ spryker.is_active AS spryker_is_active
95
+ FROM spryker
96
+ JOIN mongo ON spryker.product_offer_reference = mongo.product_offer_reference
97
+ WHERE spryker.query = 'reference'
98
+ """
99
+
100
+ print("Query:")
101
+ print(query1.strip())
102
+ print()
103
+
104
+ # Debug: Check what data we have
105
+ print("\n[DEBUG] Checking data...")
106
+ print("Spryker product_offer_reference values:")
107
+ for record in spryker_data:
108
+ print(f" - {record.get('product_offer_reference')} (query: {record.get('query')})")
109
+ print("\nMongoDB product_offer_reference values:")
110
+ for record in mongo_data:
111
+ print(f" - {record.get('product_offer_reference')}")
112
+
113
+ results = []
114
+ try:
115
+ for row in engine.query(query1):
116
+ results.append(row)
117
+ print(f" Result: id={row.get('id_product_offer')}, mongo_price={row.get('mongo_price')}, spryker_price={row.get('spryker_price')}")
118
+ except Exception as e:
119
+ print(f" [ERROR] {e}")
120
+ import traceback
121
+ traceback.print_exc()
122
+ return False
123
+
124
+ print(f"\n[OK] Query 1 completed successfully: {len(results)} rows")
125
+
126
+ # Test query 2: Simple join without WHERE clause (to test join matching)
127
+ print("\n[4] Testing simple join query (no WHERE clause)...")
128
+ print("-" * 70)
129
+ query2 = """
130
+ SELECT
131
+ spryker.id_product_offer,
132
+ spryker.product_offer_reference,
133
+ mongo.price AS mongo_price,
134
+ spryker.gross_price AS spryker_price
135
+ FROM spryker
136
+ JOIN mongo ON spryker.product_offer_reference = mongo.product_offer_reference
137
+ """
138
+
139
+ print("Query:")
140
+ print(query2.strip())
141
+ print()
142
+
143
+ results2 = []
144
+ try:
145
+ for row in engine.query(query2):
146
+ results2.append(row)
147
+ print(f" Result {len(results2)}: id={row.get('id_product_offer')}, ref={row.get('product_offer_reference')}, mongo_price={row.get('mongo_price')}, spryker_price={row.get('spryker_price')}")
148
+ except Exception as e:
149
+ print(f" [ERROR] {e}")
150
+ import traceback
151
+ traceback.print_exc()
152
+ return False
153
+
154
+ print(f"\n[OK] Query 2 completed successfully: {len(results2)} rows")
155
+
156
+ # Verify we got matches
157
+ if len(results2) == 0:
158
+ print(" [WARNING] No matches found - this might indicate a join issue")
159
+ else:
160
+ print(" [SUCCESS] Join is working correctly!")
161
+
162
+ # Summary
163
+ print("\n" + "=" * 70)
164
+ print("TEST SUMMARY")
165
+ print("=" * 70)
166
+ print(f"[OK] Query 1 (with duplicate columns): {len(results)} rows")
167
+ print(f"[OK] Query 2 (simple join): {len(results2)} rows")
168
+ print("\n[OK] All tests passed! Polars fixes are working correctly.")
169
+ return True
170
+
171
+ except Exception as e:
172
+ print(f"\n[FAILED] TEST FAILED: {e}")
173
+ import traceback
174
+ traceback.print_exc()
175
+ return False
176
+ finally:
177
+ # Cleanup
178
+ for f in [mongo_file, spryker_file]:
179
+ if os.path.exists(f):
180
+ os.remove(f)
181
+ print(f" Cleaned up {f}")
182
+
183
+ if __name__ == "__main__":
184
+ success = test_reconciliation_query()
185
+ sys.exit(0 if success else 1)
186
+
@@ -0,0 +1,147 @@
1
+ """
2
+ Direct test of Polars schema inference and duplicate column fixes.
3
+ """
4
+
5
+ import json
6
+ import tempfile
7
+ import os
8
+ from pathlib import Path
9
+ import sys
10
+
11
+ sys.path.insert(0, str(Path(__file__).parent))
12
+
13
+ from streaming_sql_engine import Engine
14
+
15
+ def test_schema_inference_fix():
16
+ """Test that mixed types (string/numeric) don't cause schema inference errors."""
17
+ print("=" * 70)
18
+ print("TEST 1: Schema Inference Fix (Mixed Types)")
19
+ print("=" * 70)
20
+
21
+ # Create data with mixed types - some prices as strings, some as numbers
22
+ mixed_data = [
23
+ {"id": 1, "price": "14.95", "name": "Product 1"}, # String price
24
+ {"id": 2, "price": 15.50, "name": "Product 2"}, # Numeric price
25
+ {"id": 3, "price": "20.00", "name": "Product 3"}, # String price
26
+ {"id": 4, "price": 25.75, "name": "Product 4"}, # Numeric price
27
+ ]
28
+
29
+ # Create JSONL file
30
+ test_file = "test_mixed_types.jsonl"
31
+ with open(test_file, 'w') as f:
32
+ for record in mixed_data:
33
+ f.write(json.dumps(record) + '\n')
34
+
35
+ try:
36
+ engine = Engine(debug=False, use_polars=True)
37
+
38
+ def load_data():
39
+ with open(test_file, 'r') as f:
40
+ for line in f:
41
+ if line.strip():
42
+ yield json.loads(line)
43
+
44
+ engine.register("products", load_data, filename=test_file)
45
+
46
+ # Query that uses Polars join (will trigger schema inference)
47
+ query = """
48
+ SELECT p1.id, p1.price, p2.price AS other_price
49
+ FROM products p1
50
+ JOIN products p2 ON p1.id = p2.id
51
+ """
52
+
53
+ results = list(engine.query(query))
54
+ print(f"[OK] Query executed successfully: {len(results)} rows")
55
+ print(f"[OK] No schema inference errors!")
56
+ return True
57
+
58
+ except Exception as e:
59
+ if "could not append value" in str(e) or "infer_schema_length" in str(e):
60
+ print(f"[FAILED] Schema inference error still occurs: {e}")
61
+ return False
62
+ else:
63
+ print(f"[ERROR] Unexpected error: {e}")
64
+ import traceback
65
+ traceback.print_exc()
66
+ return False
67
+ finally:
68
+ if os.path.exists(test_file):
69
+ os.remove(test_file)
70
+
71
+ def test_duplicate_column_fix():
72
+ """Test that duplicate column selections don't cause errors."""
73
+ print("\n" + "=" * 70)
74
+ print("TEST 2: Duplicate Column Name Fix")
75
+ print("=" * 70)
76
+
77
+ # Create simple data
78
+ data = [
79
+ {"id": 1, "price": "10.00", "name": "Product 1"},
80
+ {"id": 2, "price": "20.00", "name": "Product 2"},
81
+ ]
82
+
83
+ test_file = "test_duplicate.jsonl"
84
+ with open(test_file, 'w') as f:
85
+ for record in data:
86
+ f.write(json.dumps(record) + '\n')
87
+
88
+ try:
89
+ engine = Engine(debug=False, use_polars=True)
90
+
91
+ def load_data():
92
+ with open(test_file, 'r') as f:
93
+ for line in f:
94
+ if line.strip():
95
+ yield json.loads(line)
96
+
97
+ engine.register("products", load_data, filename=test_file)
98
+
99
+ # Query with duplicate column selection (same column selected twice)
100
+ query = """
101
+ SELECT
102
+ products.price,
103
+ products.price AS price_alias,
104
+ products.id
105
+ FROM products
106
+ """
107
+
108
+ results = list(engine.query(query))
109
+ print(f"[OK] Query executed successfully: {len(results)} rows")
110
+ print(f"[OK] No duplicate column name errors!")
111
+
112
+ # Verify results have correct columns
113
+ if results:
114
+ row = results[0]
115
+ print(f"[OK] Result columns: {list(row.keys())}")
116
+ if 'price' in row and 'price_alias' in row:
117
+ print(f"[OK] Both 'price' and 'price_alias' present in results")
118
+ else:
119
+ print(f"[WARNING] Expected columns not found")
120
+
121
+ return True
122
+
123
+ except Exception as e:
124
+ if "duplicate output name" in str(e) or "duplicate column" in str(e):
125
+ print(f"[FAILED] Duplicate column error still occurs: {e}")
126
+ return False
127
+ else:
128
+ print(f"[ERROR] Unexpected error: {e}")
129
+ import traceback
130
+ traceback.print_exc()
131
+ return False
132
+ finally:
133
+ if os.path.exists(test_file):
134
+ os.remove(test_file)
135
+
136
+ if __name__ == "__main__":
137
+ test1 = test_schema_inference_fix()
138
+ test2 = test_duplicate_column_fix()
139
+
140
+ print("\n" + "=" * 70)
141
+ print("SUMMARY")
142
+ print("=" * 70)
143
+ print(f"Schema Inference Fix: {'PASSED' if test1 else 'FAILED'}")
144
+ print(f"Duplicate Column Fix: {'PASSED' if test2 else 'FAILED'}")
145
+
146
+ sys.exit(0 if (test1 and test2) else 1)
147
+