Skip to content

Hotfix for left outer join#11571

Merged
StpMax merged 3 commits into
mainfrom
hotfix/CONN-1470-2
Sep 17, 2025
Merged

Hotfix for left outer join#11571
StpMax merged 3 commits into
mainfrom
hotfix/CONN-1470-2

Conversation

@StpMax

@StpMax StpMax commented Sep 15, 2025

Copy link
Copy Markdown
Contributor

Description

The same as #11547 but to main

Fix renderer for left outer join:

from mindsdb_sql_parser import parse_sql
from mindsdb.utilities.render.sqlalchemy_render import SqlalchemyRender
astq = parse_sql("select * from ta left outer join tb")
SqlalchemyRender("postgres").get_string(astq)
# SELECT * FROM ta JOIN tb ON 1=1   <-- previous result
# SELECT * FROM ta LEFT OUTER JOIN tb ON 1=1 <-- new result

Type of change

(Please delete options that are not relevant)

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ⚡ New feature (non-breaking change which adds functionality)
  • 📢 Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • 📄 This change requires a documentation update

Verification Process

To ensure the changes are working as expected:

  • Test Location: Specify the URL or path for testing.
  • Verification Steps: Outline the steps or queries needed to validate the change. Include any data, configurations, or actions required to reproduce or see the new functionality.

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

@entelligence-ai-pr-reviews

Copy link
Copy Markdown
Contributor

🔒 Entelligence AI Vulnerability Scanner

❌ Security analysis failed: Security analysis failed: 404: template 'bp1y9rqvhhvvfpvdc4n5' not found

@entelligence-ai-pr-reviews

Copy link
Copy Markdown
Contributor

Review Summary

🏷️ Draft Comments (2)

Skipped posting 2 draft comments that were valid but scored below your review threshold (>=13/15). Feel free to update them here.

mindsdb/utilities/render/sqlalchemy_render.py (2)

577-578: RIGHT JOIN is not supported and raises NotImplementedError, causing valid SQL queries with right joins to fail unexpectedly.

📊 Impact Scores:

  • Production Impact: 3/5
  • Fix Specificity: 2/5
  • Urgency Impact: 2/5
  • Total Score: 7/15

🤖 AI Agent Prompt (Copy & Paste Ready):

In mindsdb/utilities/render/sqlalchemy_render.py, lines 577-578, the code raises NotImplementedError for any join type containing 'RIGHT', which causes valid SQL queries with RIGHT JOIN to fail. Remove the check for 'RIGHT' in join_type so that RIGHT JOINs are handled (mirroring how LEFT JOINs are handled). Only raise NotImplementedError for 'ASOF' joins.

517-654: The prepare_select function (lines 517-654) is over 130 lines long, handling multiple SQL clause types and join logic, making it difficult to maintain and extend as SQL complexity grows.

📊 Impact Scores:

  • Production Impact: 2/5
  • Fix Specificity: 4/5
  • Urgency Impact: 2/5
  • Total Score: 8/15

🤖 AI Agent Prompt (Copy & Paste Ready):

Refactor the `prepare_select` method in `mindsdb/utilities/render/sqlalchemy_render.py` (lines 517-654). The function is over 130 lines and handles many SQL clause types and join logic, making it hard to maintain and extend. Break it into smaller, well-named helper methods for each major clause (e.g., CTE, FROM/JOIN, WHERE, GROUP BY, ORDER BY, LIMIT/OFFSET, etc.), and orchestrate them from a concise `prepare_select` method. Preserve all logic and ensure functional equivalence.

@StpMax StpMax merged commit 6f8b193 into main Sep 17, 2025
21 checks passed
@StpMax StpMax deleted the hotfix/CONN-1470-2 branch September 17, 2025 08:49
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants